textmate - Regex to Find a Word Inside Curly Braces -


i need way search text using regex , find word thats inside latex command (which means it's inside curly braces)

here example:

tarzan name , knows {tarzan loves jane} 

now if search regex: ({[^{}]*?)(tarzan)([^}]*}) , replace $1t~a~r~z~a~n$3

this replace word tarzan inside curly braces , ignore other instance! far came.

now need same following example:

tarzan name , knows {tarzan loves jane} doesn't know because written \grk{tarzan loves jane} 

in example need last mention of "tarzan" replaced (the 1 within \grk{})

can me modify above regex search that?

you can try use pattern:

(?:\g(?!\a)|\\grk{)[^}]*?\ktarzan 

demo

details:

(?:     \g(?!\a)  # contiguous previous match   |           # or     \\grk{    # first match ) [^}]*?        # not } (non-greedy) until ... \k            # reset start of match @ position tarzan        # ... target word 

note: \g matches position after previous match, matches start of string too. that's add (?!\a) prevent match @ start of string.

or can use: \\grk{[^}]*?\ktarzan multiple pass.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -