Thread:Extension talk:Arrays/Printing with spaces in delimiter

Is there any way to print a space in the delimiter, or to prevent spaces from being lost if the delimiter borders on a space?

I have to parse a string to escape wiki links, i.e., take in a string like "something with a link", split it at the using /\[\[/ as the delimiter, and print "something with a $OpenWikiLink$link" , but what I get is "something with a$OpenWikiLink$link]]" , trimming off the space.

At the moment, I'm working around this by escaping all spaces to &amp;#32;, by splitting the string with /\s/ as the delimiter and printing with &amp;#32; as the delimiter, but replacing real spaces with &amp;#32; isn't ideal, as spaces do sometimes have meaning in wikitext.

I'd prefer, if it's not possible to avoid loss of spaces near the spilt, to also escape the spaces, and then be able to split on my escape for spaces and print real spaces as the delimiter, but I haven't been able to find a way to print spaces in the delimiter...even tried to create a template that contains a single space, and use that as the delimiter, but it doesn't seem to work.