in reply to Regarding Regular Expressions
your string: abcdefghijklfghijklabcdefg
Here is one example s/e.*fg/eXfg/;
abcdeXfg
As you see it took e, followed by anything, followed by fg and is greedy.
This is a little more like I think you want s/efg/eXfg/g;
abcdeXfghijklfghijklabcdeXfg
This looks for efg, the g modifier tells it to keep looking (global)
or perhaps you meant this s/e[^e]*fg/eXfg/g;
abcdeXfghijklabcdeXfg
This is e followed by zero or more non e characters followed by fg, searched for multiple times.
here is a generic search for p1 followed by p2, by p3, with things that are not the patterns in between. s/p1[^(p1)(p2)(p3)]*p2[^(p1)(p2)(p3)]*p3/X/g;
then I guess you just count the X's or use them as markers for further processing or whatever else you needed.
cheers.
|
|---|