Replace different values with one value
-
I have done a quick google search but I am still struggling to find what I am looking for.
I am editing the XML file for a game(this is freemode so it is just for fun) where the driving skills of the characters are displayed as below.
<drivingSkill>0.8754684168</drivingSkill>
<drivingSkill>0.6954855478</drivingSkill>
<drivingSkill>0.5321546751</drivingSkill>How can I search and replace so that, in one movement, they all change to the below?
<drivingSkill>1</drivingSkill>
<drivingSkill>1</drivingSkill>
<drivingSkill>1</drivingSkill>I will add that they are not together as above, but spread throughout the XML document.
Many thanks in advance.
-
Hello, @Covertraptor90,
Very easy, Indeed !
-
Move to the very beginning of your file (
Ctrl + Origin) -
Open the Replace dialog (
Ctrl + H) -
Paste or type the following regex search
<drivingSkill>\d\.\d+</drivingSkill>, in the Find what: zone -
Paste or type the following replacement text
<drivingSkill>1</drivingSkill>, in the Replace with: zone -
Select the Regular expression search mode
-
Click on the Replace All button
Et voilà !
Notes :
-
The syntax
\dmatches any single digit, from 0 to 9 -
The escaped dot
\.stands for the decimal dot character. It must be escaped because dot is, normally, a special regex character ! -
The syntax
\d+, identical to\d{1,}, matches any non empty range of consecutive digits -
Everything else is just text, which matches itself, in, both, search and replacement !
Best Regards,
guy038
-
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login