Reputation: 45
I am searching for a regex to find all the spaces in lines starting with a specific string (in a SVN dump file). Despite the "global" modifier my regex returns only the first occurence of the space character.
A part of the file i am working on :
...
pla bla bli
Node-path: branches/BU ILD/ml_cf/syst em/Translation/TranslationManager.class.php
Node-kind: file
Node-action: change
Text-delta: true
....
The regex :
/Node-path: \S*(\ )/g
finds only the first space (between U and I) but not the others on the line.
Upvotes: 2
Views: 314
Reputation: 784958
Using PCRE regex to find all the spaces on a line starting with a particular text, use this regex:
/(?:^Node-path: |\G)\S+\K\h+/gm
(?:Node-path: |\G)
we are matching lines starting with Node-path:
OR positioning at the end of the previous match.\G
asserts position at the end of the previous match or the start of the string for the first match\K
resets the starting point of the reported match.\h+
matches 1 or more of horizontal whitespace (space or tab)Upvotes: 1