Replacing 5-digit numbers in lines that start with specific characters
-
Fellow Notepad++ Users,
Could you please help me with the following search-and-replace problem I am having?
DESCRIBE THE CIRCUMSTANCES OF YOUR QUESTION
Here is the data I currently have (“before” data):
</MouseMovementEvent> <MouseMovementEvent> <Type>2</Type> <X>23278</X> <Y>27609</Y> <Delay>1</Delay> </MouseMovementEvent> <MouseMovementEvent> <Type>2</Type> <X>23210</X> <Y>27670</Y> <Delay>1</Delay> </MouseMovementEvent> <MouseMovementEvent> <Type>2</Type> <X>23005</X> <Y>27731</Y> <Delay>1</Delay> </MouseMovementEvent> <MouseMovementEvent> <Type>2</Type> <X>22937</X> <Y>27731</Y> <Delay>1</Delay> </MouseMovementEvent> <MouseMovementEvent> <Type>2</Type> <X>22834</X> <Y>27791</Y> <Delay>2</Delay>
Here is how I would like that data to look (“after” data):
</MouseMovementEvent> <MouseMovementEvent> <Type>2</Type> <X>23278</X> <Y>27245</Y> <Delay>1</Delay> </MouseMovementEvent> <MouseMovementEvent> <Type>2</Type> <X>23210</X> <Y>27245</Y> <Delay>1</Delay> </MouseMovementEvent> <MouseMovementEvent> <Type>2</Type> <X>23005</X> <Y>27245</Y> <Delay>1</Delay> </MouseMovementEvent> <MouseMovementEvent> <Type>2</Type> <X>22937</X> <Y>27245</Y> <Delay>1</Delay> </MouseMovementEvent> <MouseMovementEvent> <Type>2</Type> <X>22834</X> <Y>27245</Y> <Delay>2</Delay> Thank you.
-
Thank you for the example data, but it would have also been nice to explain what you wanted in words.
I have interpreted your request as “How do I replace any line like
<Y>#####</Y>
with<Y>27245</Y>
, where ##### can be any 5-digit number?”.Answer:
- FIND =
<Y>\d{5}</Y>
- REPLACE =
<Y>27245</Y>
- SEARCH MODE = Regular Expression
----
Useful References
- FIND =