[pmwiki-users] ROSPatterns/regex question

James DeVain jamesdevain at mail.com
Tue Sep 26 11:44:58 CDT 2017


Hello,

I've been trying to use $ROSPatterns to change something like this:

" mary had a little lamb"

into this:

"(:word_1:mary:)(:word_2:had:)(:word_3:a:)(:word_4:little:)(:word_5:lamb:)"

I don't have much experience with regex, but what I have so far is:

$ROSPatterns ["/^\\s/"]    = "(:w1:";

which places the first "(:word_1:" in front of "mary". Now I need to find the second empty
space and change it to ":)(:word_2:". I figured I could just write a different ROSPattern
for each empty space, like:

$ROSPatterns ["/^\\s/"]    = "(:w1:";
$ROSPatterns ["...find second empty space..."]    = ":)(:w2:";
$ROSPatterns ["...find third empty space..."]    = ":)(:w3:";
... etc.

Everything I've tried either erases everything after the second space, replaces EVERYTHING
with ":)(:word_2:", has no effect at all, or some other unexpected result.

I realize that this is more of a regex question than a PmWiki question, but if anybody could
help me with this I would be very grateful.

Thanks!



More information about the pmwiki-users mailing list