Replace selected text - leaving in the middle fragment without the changes


#1

Hello
I need the help of specialists.

I have to edit a lot of chat logs (which by changing the version of the software began to be written differently) - by then I can’t import them into another program.

<message sender="GG" time="2010-01-08T17:38:1801:00" alias="Jacobs"><div><span style="font-family: Helv....
<message sender="GG" time="2010-01-08T17:38:1901:00" alias="Marucins"><div><span style="fo.........
<message sender="GG" time="2010-01-08T17:38:2301:00" alias="Marucins"><div><span style="font-......
<message sender="GG" time="2010-01-08T17:38:3101:00" alias="Jacobs"><div><span s.......
<message sender="GG" time="2010-01-08T17:38:3801:00" alias="Jacobs"><div><spa........
<message sender="GG" time="2010-01-08T17:38:5501:00" alias="Marucins"><div><span st.....

I want to replace the word “GG” where “Jacobs” to the number 12345 leaving unchanged time/date string “2010-01-0…”

It should be like this:

<message sender="12345" time="2010-01-08T17:38:1801:00" alias="Jacobs"><div><span style="font-family: Helv....
<message sender="GG" time="2010-01-08T17:38:1901:00" alias="Marucins"><div><span style="fo.........
<message sender="GG" time="2010-01-08T17:38:2301:00" alias="Marucins"><div><span style="font-......
<message sender="12345" time="2010-01-08T17:38:3101:00" alias="Jacobs"><div><span s.......
<message sender="12345" time="2010-01-08T17:38:3801:00" alias="Jacobs"><div><spa........
<message sender="GG" time="2010-01-08T17:38:5501:00" alias="Marucins"><div><span st.....

Does anyone will be able to help me?


#2

With the regular expressions option turned on:

  • Find: (sender=")GG(".+alias="Jacobs")
  • Replace: $112345$2

#3

Thanks
That’s what I wanted.
I have to think how to overtake an entire directory.

//edit
I did not notice before but there is a different format “date” :frowning:

It is:

time="2009-09-06T18:29:4202:00"

I would like to be:

time="2009-09-06T18:29:42+0200"

leedohm, can you help again?

/I would like to ask, can do these things at one time or need to separately - consecutively


#4

To convert the time, also with regex option on:

Find: (time="\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d)(\d\d):(\d\d")
Replace: $1+$2$3

Maybe there’s a more elegant solution, but I think this should replace all the dates at once :smile: