Query regarding increment operator

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
prashob12
Posts: 18
Joined: Thu Oct 25, 2007 1:31 am
Location: India

Query regarding increment operator

Post 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.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post 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.
Hope this was helpful.............good luck,
Bob
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
prashob12
Posts: 18
Joined: Thu Oct 25, 2007 1:31 am
Location: India

Post by prashob12 »

Thanks
Post Reply