Regular Expression: Digits omitted

Forum for TextAloud version 3

Moderator: Jim Bretti

Post Reply
dinoe
Posts: 12
Joined: Sun Jan 29, 2006 4:02 am
Contact:

Regular Expression: Digits omitted

Post by dinoe »

Hi there!

It´s about omitting numbers again (omit strings of 1-2-digits only and read the longer strings fully).

The precise task: what must we do to omit every string of one or two digits surrounded by space or other non-digit characters)?

With the regular expressions /d and /d/d we can easily omit a string of 1 and 2 digits... but with /d and /d/d only... the longer digit-strings ones are no longer read fully, i.e. 123 will be 3 for example or 232332 will be 2332 (first two digits subtracted)!

Greetings

dinoe
Jim Bretti
Posts: 1558
Joined: Wed Oct 29, 2003 11:07 am
Contact:

Re: Regular Expression: Digits omitted

Post by Jim Bretti »

You can use \D to match characters that are *not* digits. So you might be able to use something like this:

\D\d{1,2}\D

So this expression match one or two decimal digits only when they are not surrounded by other digits.

Does this help?
Jim Bretti
NextUp.com
dinoe
Posts: 12
Joined: Sun Jan 29, 2006 4:02 am
Contact:

Re: Regular Expression: Digits omitted

Post by dinoe »

Thanks Jim, thats very good :)
Post Reply