move * before

  • hello all
    i have a lot of lines like this
    <a href=“url/myurl.htm”>* name</a>
    i would as result to get

    • <a href=“url/myurl.htm”>name</a>

    so to put the * before <a

    i dont succeed to make a regex

  • @Pouemes44

    from the data provided I would assume this should do the trick

    find what:(<a.*?>)(\*\x20)(.*?<\/a>)
    replace with:* $1$3


  • @Claudia-Frank said:

    • $1$3

    wahoo a great thanks claudia, it works
    can you explain me how it works

  • @Pouemes44

    I’m not really good in regex explanations but I’ll give it a try.

    each of the () denote a matching group which can be reflected by using a dollar sign and a number.
    $1 for the first matching group, $2 for the second and so on.

    So what get’s matched in (<a.?>) is stored in $1,
    (*\x20) in $2 and (.
    ?</a>) in $3

    (<a.*?>) = we are looking for something which starts with <a
    followed by .* means anything either none or multiple time,
    the question mark restricts that it should be as less as possible
    chars consumed followed by >.

    (*\x20) we are looking for the asteriks and \x20 is the hexcode for a space

    and last but not least, (.*?</a>) which is basically similar to the first.

    In the replace with field you ignore the second matching group as you want to get rid of the asteriks and space,
    instead you type it in front of the $1$3 because that is what you wanted.

    Better described at


  • Hello, @pouemes44, @claudia-franck and All,

    An other solution could be :

    SEARCH (?-s)\*\x20+(?=.+?</a>)


    Notes :

    • As usual, the modifier (?-s) means that the dot, ., matches a single standard character, only

    • Then, the regex engine is looking for a literal star symbol ( \* ) followed by at least one space character ( \x20+ )

    • But, ONLY, if the look-ahead is verified. That is to say, IF it exists, further on, an ending tag </a>, on the same line

    • As the replacement zone is empty , the combination star + space(s) is simply deleted !

    Of course, if the syntax \*\x20+ occurs, ONLY, in blocks <a ......>......</a> of your file, just use :

    SEARCH \*\x20+


    Best Regards,


  • thanks both for explanations

    but guy with your solution, its only delete all *space but not move them before <a

  • and claudia i just saw that your solution does errors

    <a href="/url/page.html">name</a>
    <a href="/url/other.html">name2</a>
    <a href="/url/third.html">etc</a>
    <a href="/url/four.html">* something</a>


    • <a href="/url/page.html">name</a>
      <a href="/url/other.html">name2</a>
      <a href="/url/third.html">etc</a>
      <a href="/url/four.html">something</a>

    i would

    <a href="/url/page.html">name</a>
    <a href="/url/other.html">name2</a>
    <a href="/url/third.html">etc</a>

    • <a href="/url/four.html">something</a>

  • like this seems to works

    search (?-s)(<a.+?">)+*\x20+(?=.+?</a>)
    replace * $1

  • @guy038 said:

    this two
    replace * $1

  • @Pouemes44

    I don’t see really the difference, I guess because the markdown used some of your chars for formatting.
    To prevent this you can either indent every line with 4 spaces or escape the markdown characters with
    a backslash, like

    * whatever */

    I had just to put 4 spaces in front of the asteriks and every single character is shown whereas here


    I had to write \*whatever*/ to inform markdown that the asteriks should be displayed and not used to reformat text.

    Anyway, good to see that you have found your solution.


  • yes claudia,
    i dont know what was the poblem with your solution
    anyway i succeed
    a great thanks

  • Hi, @pouemes44, @claudia-frank and All,

    I apologize, Pouemess44, because I didn’t read your post carefully :-( I should have read the line :

    so to put the * before <a

    and, also, the title of your post !

    move * before

    So, seemingly, from the initial text :

      <a href=“url/myurl.htm”>* name</a>

    Your goal is to obtain the text below :

      *<a href=“url/myurl.htm”>name</a>

    In that case, you’re perfectly right ! A correct regex S/R is, very similar to yours, is :

    SEARCH (?-s)(<a href.+?>)\*\x20+

    REPLACE *$1



    P.S. :

    I guess that Claudia did the same mistake than me !! So, the correct Claudia’s regex S/R is, rather :

    SEARCH (<a.*?>)(\*\x20)(.*?<\/a>)

    REPLACE *$1$3

  • @guy038 said:


    hello thanks for answer
    i try also to learn
    for claudia solution i have no error if i add (?-s)

    like this

    • $1$3

    without (?-s) or with (?s) i get errors in results

Log in to reply