Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pattern Match for any number in string - CR XI

Status
Not open for further replies.

pndMaster

IS-IT--Management
Mar 6, 2013
20
0
0
US
Hello,

I would like to know how i can write a formula that will return True or False if the string has number or numbers in it.

For example
StringVar temp:="ABC 12";
Stringvar temp1:="ABC";

I would like to check temp for number and it should return true and temp1 should return false.

Appreciate the guidance and feedback

Regards
 
If you just want to see if the string has any numbers in it, you can loop through it like this:

stringvar v_string := "";
numbervar x := 1;

while x <= len({YourDBField})
do
(if isnumeric({YourDBField}[x]) then v_string := v_string + {YourDBField}[x];
x := x + 1);

if isnumeric(v_string) then "Has Numbers" else "Does Not Have Numbers
 
I would probably have done it this way:

Code:
If      {Table.Field} = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace({Table.Field},'1',''),'2',''),'3',''),'4',''),'5',''),'6',''),'7',''),'8',''),'9',''),'0','')
Then    False
Else    True

I'm not saying it is a better approach - it is just that I generally avoid variables if they are not required.

Cheers
Pete

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top