I
I
Ilya2021-07-16 10:40:26
Regular Expressions
Ilya, 2021-07-16 10:40:26

How to use regular expressions to find a word and copy it to a specific location?

Tell me, please, how can I use regular expressions to find what is written between the tags, copy it and paste it between the tags?
I've been racking my brain for an hour, I can't find a formula))

Example:

<category id="1"><name>Мужские куртки</name><short></short></category>
<category id="2"><name>Мужские брюки</name><short></short></category>
<category id="3"><name>Мужские портянки</name><short></short></category>


Need:
<category id="1"><name>Мужские куртки</name><short>Мужские куртки</short></category>
<category id="2"><name>Мужские брюки</name><short>Мужские брюки</short></category>
<category id="3"><name>Мужские портянки</name><short>Мужские портянки</short></category>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-07-16
@ilyapokrov

Find: (<name>([^<]+)</name>\s*<short>)\s*(</short>)
Replace: $1$2$3
https://regex101.com/r/3XnZO9/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question