Page 1 of 1

Query regarding increment operator

Posted: Tue Dec 04, 2007 4:20 pm
by prashob12
Hi all,

Here is what I want in the following there is a list of ID's like the following given but the condition should be that the number of digit should not exceed 4.

id="sb0001"
id="sb0002"

....
....

id="sb0020"

now while using id="sb000\i(1,1)" it shows the following output which is wrong.

id="sb0001"
id="sb0002"

....
....

id="sb00020"

Could you please let me know that whether we could give any condition to it so that the number of digit should not exceed more than 4 digit.

Kindly help.

Rgds,
Prashob N.

Posted: Tue Dec 04, 2007 5:21 pm
by Bob Hansen
Have no idea what you are doing, but you can do a search for strings with more than 4 digits.

And you could replace those string with something else. You could drop any of the digits to make a length of four, but you need to provide the rules.

If the string has 5 digits, would you drop the first, or last, or one in the middle? If the string has 8 digits, which ones would you drop?

Search for: "sb[0-9]{5,}" to find strings "sbxxxx" with 5 or more digits for the x.

Posted: Tue Dec 04, 2007 7:37 pm
by ben_josephs
I think Prashob wants 4-digit sequence numbers. Unfortunately, TextPad can't generate them directly. But, as Bob suggests, after generating the sequences numbers with an excess of leading zeros, you can trim them off:
Find what: "sb0+([0-9]{4})"
Replace with: "sb\1"

[X] Regular expression
Or, more generally:
Find what: [^0-9]0+([0-9]{4})
Replace with: \1\2

[X] Regular expression
These assume you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax

Posted: Wed Dec 05, 2007 4:18 pm
by prashob12
Thanks