Reputation: 28
I'm edit an rst file for a document. There are lot of image links I have to edit them one by one, I'd like to ask, is there anybody can help write a regular expression that can transfer it in one time.
The original text looks like:
*Figure 1.2: Where is the dog?* <dog.html#fig_dog>
I'd like it translate it to:
:ref:fig_dog
And there is another one:
*How are you* <how_are_you.html>
I'd like it translate it to:
:ref:how_are_you
I have try some expression in editplus or notepad++, but i can't match them very well.
Upvotes: 1
Views: 57
Reputation: 425043
Search:
\*.*?\*\s*<(?:.*#)?([^.>]+)(\.[^>]*)?>
Replace:
:ref:\1
Upvotes: 2
Reputation: 3109
split into two regexes
To match before the html
<(.*).html.*?>
To match the anchor
<.*.html#(.*?)>
Upvotes: 0