parsing 4 dig lon int from a string of any format

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
mr00047
Forum Newbie
Posts: 14
Joined: Fri May 12, 2006 1:01 pm

parsing 4 dig lon int from a string of any format

Post by mr00047 »

Hello

i want to return a 4 digit long integer number if found in a string in anyformat. i need to
search the string for 4 cosecutive number if found then return the number, if not found
4 consecutive number then it will return false;

can any one write the regular expression for me?

please help!
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Code: Select all

^.*\d{4}.*$
User avatar
stereofrog
Forum Contributor
Posts: 386
Joined: Mon Dec 04, 2006 6:10 am

Post by stereofrog »

Given the string "1234 xx 567890 yy 4321", what exactly should the regexp find?
Post Reply