Regex multi-line flag and anchors in EasyMorph: \A and \Z vs. ^ and $

Hello,

I was wondering which set of beginning/end anchors to use in EasyMorph, depending if the multi-line regex flag is active or not in Easymorph.

I’ve been doing some experiments with a multi-line string, and using ^ and $ instead of \A and \Z doesn’t seem to make a difference.

For example, I have the following string:

zAz
zAz
zAz
zAz

And If I apply the regexreplace(string,‘b’,’^z’), I get the following result:

bAz
zAz
zAz
zAz

In a regex expression with the multi-line flag active, ^ would be the beginning of each line, and I would get

bAz
bAz
bAz
bAz

In the case of applying \A (the absolute beginning) instead of ^, so regexreplace(string,‘b’,’\Az’), I get the following, which is correct:

bAz
zAz
zAz
zAz

This means that the multi-line regex flag is deactivated by default in regex in EasyMorph right? Is there a way to activate/deactivate regex flags?

Thanks,

Roberto

Hello @roberto,
You can specify options in regex pattern.

Check link for more details:

In yout specific case you need to write expression like this:
regexreplace(string,‘b’,’(?m)^z’)

Reemplazarcaracteres.morph (1.9 KB)