Search for a multiple variable number
-
Hello,
I need help to search a multiple variable text in a lots of lines.
For example, I have this part who is always in the same format:/ xxx xxx xxx 255 /
/ xx x xxx 255 /Or something like this, and i want to replace this by
/ 238 46 231 255 /
How can I do ?
Thanks for your help
-
@Paul-Carfau said in Search for a multiple variable number:
/ xxx xxx xxx 255 /
/ xx x xxx 255 /
Or something like this, and i want to replace this by
/ 238 46 231 255 /(?=/.*255 /)(/.*255 /=?)
-
-
I take it the
x
in your example are digits and the empty space is really simply a single space character?If so, then then searching for
/\s\d{3}\s\d{3}\s\d{3}(?=\s255)
and replacing with/ 238 46 231
would work for your first example (set Regular expression mode).For your second example, do another replacement and tweak the first one slightly. Hint: Substitute different numbers inside the
{
and}
. -
@gurikbal-singh @Alan-Kilborn
I just realized by rereading my post that I forgot a precision. Your answers are correct, but my case is more complex because my lines are in this form:-38.2845993 41.9356995 -1.9463000 / 0.0000000 0.0000000 -1.0000000 / 0 0 0 255 / 0.0005000 0.4144570
-38.2499008 41.5647011 6.4520898 / 0.5073535 0.0000000 0.8617381 / 22 30 34 255 / 0.9995010 0.4144000and I wish to change this way :
-38.2845993 41.9356995 -1.9463000 / 0.0000000 0.0000000 -1.0000000 / 238 46 231 255 / 0.0005000 0.4144570
-38.2499008 41.5647011 6.4520898 / 0.5073535 0.0000000 0.8617381 / 238 46 231 255 / 0.9995010 0.4144000And I do not find a solution despite having spent time on the forums …
-
If the “precision” is just that the
x
’s can be “up-to” three digits, then use @Alan-Kilborn’s solution slightly modified:\s\d{1,3}\s\d{1,3}\s\d{1,3}(?=\s255)
Cheers.
-
Your my god, thanks a lot man !