Hi, I need some help please.
I asked a question some time back on this site, and now i need another answer.
take this setup for example:
BEGIN “[i 0]” Type Wife Age 7200.000 SkinColour 0x000000ff END
BEGIN “[i 1]” Type Son Age 7200.000 SkinColour 0x000000ff END
BEGIN “[i 2]” Type Tree SubType 5 Pos.x 10.49121 Pos.y 111.7811 Age 7200.000 END
BEGIN “[i 3]” Type Tree SubType 2 Pos.x 13.77533 Pos.y 34.22266 Age 7200.000 END
someone already told me how to modify the “Age” of a “Tree” earlier…
? Open the Replace dialog ( CTRL + H )
? Select the Regular expression search mode
? Preferably, check the Match case option
? Check the Wrap around option, if necessary
? In the Find What zone, type Age \K.+(?= END)
Remark : There a space, before the word Age AND after it, as well as before the word END !
? In the Replace with zone, type, simply, the string 7200.000
? Click on the Replace All button
but HERE IS THE QUESTION: how do i alter the steps to make sure it only includes the “Tree” Age??
I mean, when I change the “Age” of a tree…it also changes the age of the “wife”, “son”, ect… there must be a way to make sure it searches for the “Age” of a “Tree” only…
there is no hint of tree in your regex.
Tree .+ Age \K.+(?= END)
would do it if the layout is as you posted.
that didn’t really work…im not sure why…in my document that only changed one out of 151 “Tree” ages. was there suppose to be an extra space or something, because when I try to find values it just highlights everything, and when I just click replace all it only says 1 replaced…I know there are more trees in that file…
Without knowing your data it is really hard to say what could have caused it.
The syntax of the regex is
Space followedby Tree followedby Space followedby “as much chars as possible until” Space followedby Age followedby Space
\K = reset startingpoint to current position
.+ = “as much chars as possible until” Space followedby END (but Space followedby END is a lookahead.
I duplicated your example data and it replaced all lines having Tree … Age
Is it possible that different case is used?
Did you check MatchCase?
Did you check WrapArround?
ok that’s what it was…finally thank you so much Claudia.
Seemingly, I replied to your identical post, on the Help forum, at the address :
I haven’t noticed this post on the Discussion forum !
As you can see, we, both, get the same regex. Finally, I think that the
$assertion, that I added, at the end of my regex, is useless. Indeed, as the
+is a greedy quantifier, it will, anyway, select the longest text, after the string "Age " till the ending string " END" !