python-rex icon indicating copy to clipboard operation
python-rex copied to clipboard

TODO: Escape characters in patterns

Open cypreess opened this issue 12 years ago • 4 comments

cypreess avatar Jun 26 '13 07:06 cypreess

explain ?

toutouastro avatar Jun 28 '13 12:06 toutouastro

rex parses it's input to match something like [m|s]<delimiter>pattern<delimiter>substituion<delimiter>[flags]. eg.

s/dog/cat/i

Matching is VERY trivial and it will not work if you use delimiter character inside of the pattern, e.g.: substitution of all http: to http://

s/http:/http:/// usually you should write it like s/http:/http:\/\// - but none of those two ways will work right now.

However it can be easily solved by using other delimiter:

s!http:!http://!

The only thing is you are not allowed to use delimiter character inside pattern right now.

cypreess avatar Jun 28 '13 16:06 cypreess

so you should give the user the option to modify the delimiter character ?

toutouastro avatar Jun 28 '13 16:06 toutouastro

It's already there. The same as in perl you can write s/dog/cat/ or s?dog?cat? or whatever s!dog!cat!. rex automatically detects what is the delimiter sign. Check the source code.

cypreess avatar Jun 28 '13 17:06 cypreess