How to loop regular expression?

I need help with a simple task

Here are some of the possible values than need changing:


And here is how they all should look like when the action is executed upon them


All I have know is this code for format value

$regexp(%GENRE%,'9XX','9X')With this code the change is done, but only once; and only on capital letters . So it would have to be executed every time unknown amount of times in order to really do the job and with a second version for lower letters and third version taking into account >Xx< and >xX< possibilities

So how do I merge those tasks into one line and loop them until there are no lower and upper case x's left, that are adjacent specifically to >>#9<<


Your format regexp shows a different string than the first example.

Just remove the #* and # from the above depending.

^ match start of string
(?i) turn on case insensitivity


  • matches above any number of times. 0 to infinity
    9 a literal, number 9. Change this to \d if you want to match any digit
    x another literal like above
  • matches x any number of times like # above

Example for single value in tag-field:


Result: #9X

... or ...

Example for floating value within tag-field:

$regexp(' test \r \n #9xXXXXXXx \r\n test','(?:.*)(#\d+)(\D)(?:.*)','$1\u$2')

Result: #9X

DD.20170731.2026.CEST, DD.20170801.0754.CEST

String, and not the whole tag field?

I am making sure because [as always] I did not precise enough: there can be many other values in that tag field; and they all must be left alone exactly as they are. I only need to treat x's [and later on other variations of numbers and letters, to which I will modify the descibed / received code]

What's in the field is a string. A string is a line of text.

Search google for what these regular expression character classes are for



Basically, these two char classes anchor the search for the regular expression to either the start ^ or end $ of the string.

Meaning the string needs to begin with what regular expression follows. 15minutes on youtube would get you understanding how the basics work.
One vid of thousands on youtube:

Why not just post full examples of what you want?

For your needs remove the ^

One textual tagfield contains only one string of characters.

Why don't you distribute the distinguishable data into different tag fields?
This way each different dataset would be accessible by its own tag-field name.
And repairing the incorrect data would be easier.


So it is impossible to loop on something from the middle, especially when it is unknown where exactly it will be [with it beeing sometimes at the very beginning or at the very end or somewhere in the middle]?

But I did list some examples

Normally I just put [in this case] >>##9X<< via the actions, to avoid mistakes

But sometimes I'm just writing [changing, correcting] with a keyboard. I shouldn't do it [to avoid mistakes] but it is easier and quicker sometimes to write just >>9x<< or >>x<< [as I already have big clearing action that takes care of such incomplete codes and turns them into >>##9X<<]. And so I need to not take notice if by mistake there are two x's or three, because of a stuck key or a slip of a finger

Because that would end me up with something like a worksheet in Excel, filled with dozens of columns, but most of witch for most of the time would be empty; and still there would have to be one very wide column to house codes with words and not just with two digits [numbers and combinations o a digit and a letter]. I would need to constantly turn on and off such columns or scroll the view horizontally or work on something like two widescreen monitors. And the numbers of errors coming such unclear views would be horrendous

Instead of that I have one column / tag field to house all the codes [my genres in form of codes]

I just have found a neat solution

I can just simply use "Replace with regular expression"

Field: GENRE
Regular expression: 9xx+
Replace matches with: 9XAnd that it is; it works. I have tested it and it does not messed up other values

But of course thank you both for your time

No, no, no.



Your example won't replace 9x with 9X like you wanted or maybe I'm missing something again.

You are correct

But change from 9x to 9X is done at some other point with other action; while at this point 9xx serves as a kind of fail safe

In which case:

\b9x+\b will match only 9xx in these scenarios.
wordhere 9xXxXxx wordhere
wordhere.9xxxX wordhere
9xXxX wordhere
word here 9xxXx

But NOT these.

wordhere9xXxX wordhere
wordhere 9xXxXwordhere
word here9xxXx
\b in regular expressions searches for word boundaries. I think this is what you're after. I wouldn't know as you've yet to post full examples.
QUOTE (stevehero @ Aug 2 2017, 00:20) <{POST_SNAPBACK}>

But NOT these.

wordhere9xXxX wordhere
wordhere 9xXxXwordhere
word here9xxXx


Point taken

But all values are marked with markers ["##"] and other action takes care of putting / checking them

And such cases like those above I surely would not want to be treated automatically, because they can indicate a big mess [and as such have to be evaluated manually; or automatically by simply wiped out, which is what happens now in my system]