only replace exact numbers
-
@Terry-R It works perfectly :) Thanks a lot!
-
@Cynic said in only replace exact numbers:
the XXX is just for any numbers really
With the addition of this info it doesn’t seem like the regex works.
-
@Alan-Kilborn said in only replace exact numbers:
With the addition of this info it doesn’t seem like the regex works.
Well I used the following for the test:
0.5 something 0.5 nothing here 0.5434 0.4 doesn't really matter to me 0.5 help I'm last in line!
and then after my regex was run I have:
0.3 something 0.3 nothing here 0.5434 0.4 doesn't really matter to me 0.3 help I'm last in line!
Looks like it worked. Am I missing something?
Terry
-
Nope, sorry,
I read what the OP wanted wrongly.I’m (generally) not one to “shorten” regexes that work, but what about this pair as illustrating a different technique for this situation:
find:
0\.5(?=\D)
repl:0.3
-
It can be like that?
Find What:0\.5\s
Replace With:0.3\s
Even easier instead of
\s
you can insert a space -
@Olivier-Thomas said in only replace exact numbers:
Even easier instead of \s you can insert a space
Not necessarily.
OP did not include info about whitespace.
That was inferred in the example data @Terry-R provided, which may or may not be indicative of the situation the OP has.
Unless I’m reading it wrongly yet again (very possible!).It really wouldn’t be up for debate if the OP had just provided the same thing we ask for here again and again and again, and most of the time we don’t get: Sample BEFORE and sample AFTER data!
-
Unfortunately, I can only answer after 20 minutes.
I am for shortening.
instead of this
([2-3]|0[2-3]|00[2-3]|[2-9][2-3]|0[2-9][2-3]|\d[02-9][2-3])
it’s better to write like this:
((\d[02-9]|[2-9])*)[2-3]
-
@Olivier-Thomas said in only replace exact numbers:
Unfortunately, I can only answer after 20 minutes.
That is because you previously ruined your reputation here.
I am for shortening.
IMO shortening something that works has little value…if we’re talking about a one-off replacement op in a text file in Notepad++.
Now, shortening something that is used in a production program, well, that could be a different story.
Sure, shortening a regex can make it more efficient.
But sometimes shortening a regex actually has to make the regex engine work harder (i.e., take more processing time, possibly overflow, etc) or invites more “risk”. Do we want this in a production environment? I’d say no.So, the true answer, again IMO, cannot be the simple one of “I am for shortening”. But…you go ahead believing what you want to. :-)
Note to future readers: The regex that @Olivier-Thomas put forth in the previous posting has nothing to do with the original-poster’s problem.
-
In the IVONA voice-over for film subtitles
I have over 6000 abbreviated commands.I did not notice that the IVONA lector did not keep up with reading the text.
-
@Olivier-Thomas said in only replace exact numbers:
In the IVONA voice-over for film subtitles
I have over 6000 abbreviated commands.
I did not notice that the IVONA lector did not keep up with reading the text.I’m not sure what this means.
Do you care to explain a bit, if it is relevant?
After 20 minutes, of course… :-)