Sign in to follow this  
Followers 0
Guest sjana

regular Expression

4 posts in this topic

I want to check if all digits in a string are same. E.G. my valid sets are

1. 9999999999

2. 99-99-99999

The regexp which I could come up is

^[0-9]\1+$

The above regexp match 1. but cant match 2. I need a regexp which can match both 1. and 2. thanks in advance

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

this script can do the test for you:

$a="9999999999"

$b="99-99999999"

If StrTest($a,$:whistle:=1 then

msgbox(0,"","$a is Equal to $b")

else

msgbox(0,"","$a Not Equal to $b")

endif

Func StrTest($S1,$S2)

$ignore="-,/,$" ; Place here the chars to ignore

$chars=StringSplit($ignore,",")

;

$S2b=$S2 ; Fill teststring

; Remove all specified Ignore characters from the Test string

For $x = 1 to $chars[0]

$S2b = StringReplace($S2b,$chars[$x],"")

next

If $S1=$S2b then return 1

return 0

endfunc

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks for the reply, however my requirement is a single regular expression rather than a function. Basically i need it as part of struts validation.

Share this post


Link to post
Share on other sites

The back-referencing you are asking for is on the TO DO list. I am trying to get more fundemental fixes done, before implementing it. I will be at my parent's place from Dec 22 to Jan 4, so very little development (but much relaxation) will occur then. I hope to get things finshed on the weekend and submit to Jon on Monday or Tuesday.


David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0