2 ms·
Glad you liked what you saw! Yes there is syntax reserved for backtracking constructs. It all starts with !! so you can audit it. https://www.oilshell.org/re
by chubot 6y ago
Glad you liked what you saw!
Yes there is syntax reserved for backtracking constructs. It all starts with !! so you can audit it.
https://www.oilshell.org/release/0.8.7/doc/eggex.html#backtracking-constructs-use-discouraged https://www.oilshell.org/release/0.8.7/doc/eggex.html#backtr...
So I think your example would be something like:
var pat = / 'my_fn(LIBNAME MyLib VERSION '
dot*
!!AHEAD(' REQUIRED)')
/
(since we translate only to ERE at the moment this isn't implemented, but space is reserved in the language)
Not sure what \K is offhand. Oh that's to replace the whole thing?
Can you just use 2 groups, like this?
var pat = / <'my_fn(LIBNAME Mylib VERSION '>
dot*
<' REQUIRED)'>
/
Then you replace it with '$1 ^1.2.3 $2' essentially.
I forget if sed has submatches. I know it has the weird & for $0.
But if not then you can use eggex with perl -pie. You can use either the lookahead style (in theory), or the submatch style (already supported).
Let me know if that doesn't make sense... I think this is a good example to work through the APIs