Counter of intrement

A place to try and solve your RegEx problems.
Post Reply
User avatar
Casey Basichis

Counter of intrement

Post by Casey Basichis »

Hi,

Is there any way to add an incrementing counter in a regex command?

I read that if the search contains a *[0-9], a %0> will add an incrementing number, but I haven't been able to get it to work.

The search text is id=""

The regular expression is : id="*[0-9]"

The replace text is : id="%>"

Any help would be greatly appreciated
User avatar
Casey Basichis

Post by Casey Basichis »

Sorry that was increment

Note, I was trying the replace text with both %> and %0> neither worked.

i also cant get id="" to recognize with id="*[0-9]"

I placed a temporary id="1" for testing which does recognize but the replacement looks like

id="%>"
User avatar
Fool4UAnyway

Post by Fool4UAnyway »

Try id="[0-9]*" instead of id="*[0-9]".

The asterisk * goes for the match before it, so your original regex searches for any string of consecutive double quote marks, or none at all and requires one and only one digit to follow.

You may use \d for [0-9]. It is shorter and easier.

\d+ = any string of digits requiring at least one = a number
\d* = any string of digits or none at all = nothing or a number
User avatar
zdv

Post by zdv »

Replace Counters "%0>" aren't part of .NET (TextCrawler) regular expressions. I think the example you gave relates to a custom command from another piece of software.

Post Reply