Better to use /JMATCHQ instead of /JMATCH - It is a bit more verbose, but much faster.
Assuming your StartTriggerString and EndTriggerString are always on the same line, and you want to capture all occurrences, then you just need the vanilla ? operator to make a search non greedy (stop at the earliest point possible)
Code: Select all
call jrepl "StartTriggerString(.*?)EndTriggerString" "$txt=$1" /jmatchq /f input.txt
If you only want the first occurrence on each line:
Code: Select all
call jrepl "StartTriggerString(.*?)EndTriggerString.*" "$txt=$1" /jmatchq /f input.txt
If you want only the first occurrence in the entire file:
Code: Select all
call jrepl "StartTriggerString(.*?)EndTriggerString.*" "$txt=$1;quit=true" /jmatchq /f input.txt
If the content between the start and end triggers can span multiple lines and you want all occurrences, then add the /M option and use [\s\S] to match all characters including \r and \n:
Code: Select all
call jrepl "StartTriggerString([\s\S]*?)EndTriggerString" "$txt=$1" /m /jmatchq /f input.txt
If you only want the first occurrence in the file:
Code: Select all
call jrepl "StartTriggerString([\s\S]*?)EndTriggerString[\s\S]*" "$txt=$1" /m /jmatchq /f input.txt
Dave Benham