This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

regexp - help

Old posts that have not been replied to for several years.
Locked
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

regexp - help

Post by EEggy »

Hi,
could you please help me to write the regexp for the following?

if nick has just one digit at the end? like tim9, kim4..etc?

[regexp {.*([0-9]){1,}.*} $nick]}


thanks & happy new year
EEggy
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

maybe something like:

Code: Select all

regexp {([^0-9][0-9]$){1}} $nick
of course... you could always just use string functions like string index, string is... etc...
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Thank you much, it worked.

but it also works for "t1s3t2" as well, how do i make sure, it should just check the only last number in the nick, in this example last number is 2, but also 1 and 3 are there too, so it should ignore this type..

thanks again
EEggy
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

I haven't tested this thoroughly but it may be what you're after...

Code: Select all

regexp {^[^0-9]*([0-9]$){1}} $nick
else... see the manual page entry for re-syntax.
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Thanks again, perfect.
EEggy
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Hi strikelight <- regexp's expert.

could you please help me again? advance thanks
regexp {^[^0-9]*([0-9]$){1}} $nick works perfect if nick has number at the end.

if nick has slash(\), breakets ] or [ , or ' at the end, like the above for numbers.

like -> test\ or test[ or test] or test`
and if underscore at the end or start, like test_ or _test


thanks
EEggy
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

already answered here.
Locked