Pattern Matching

29 views
Skip to first unread message

Chris Long

unread,
Jan 20, 2012, 11:12:56 AM1/20/12
to reality-...@googlegroups.com

Greetings,

 

I am trying to use pattern matching to invalidate strings that may contain an asterisk *.  Any other character is valid.  I want to use pattern matching if at all possible.  I must be able to detect and display an error if one is encountered.  Is there such a thing as a logical NOT within Databasic pattern matching?

 

Can someone suggest a way to do this using pattern matching?

 

 

For instance, all of the following should produce an error:

 

  1. *
  2. ABC*
  3. ABC*123
  4. ABC,*;123
  5. etc…

 

Chris Long

RA Services

José P. Junco Ivern

unread,
Jan 20, 2012, 11:19:38 AM1/20/12
to reality-...@googlegroups.com

IF INDEX(VARIABLE,’*’,1) THEN

  PRINT ‘AN * EXIST …..’

  PRINT  ‘INSERT HERE ALL THE OTHERS FUNCTIONS/COMMANDS THAT APPLIES …..’

END ELSE

  PRINT ‘AN * DOES NOT EXIST …..’

  PRINT  ‘INSERT HERE ALL THE OTHERS FUNCTIONS/COMMANDS THAT APPLIES …..’

END

 

OR

 

IF INDEX(VARIABLE,’*’,1)  ELSE

  PRINT ‘AN * DOES NOT EXIST …..’

  PRINT  ‘INSERT HERE ALL THE OTHERS FUNCTIONS/COMMANDS THAT APPLIES …..’

END

 

Note :

·         Assumes that VARIABLE is that or a Dynamic Array with the content that has the value being checked

·         There are , of course , several other ways of doing it but this set of instructions over here has done the job for us in the past.

Saludos,

José

======================
José P. Junco-Ivern
Rovira Biscuit Corporation
Rovira Foods, Inc.
Urb. Buena Vista
619 Ave. La Ceiba
Ponce, PR  00717-1901
Tel : 787-844-8585 ext 2115
Office Desk Direct No. : 787-651-2462
Fax : 787-848-7176
jju...@rovira.com
=======================
Description: roviralogo

 

--
You received this message because you are subscribed to the Google Groups "Reality" group.
To post to this group, send email to reality-...@googlegroups.com.
To unsubscribe from this group, send email to reality-databa...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/reality-database?hl=en.

image003.jpg

Chris Long

unread,
Jan 20, 2012, 11:34:03 AM1/20/12
to reality-...@googlegroups.com

José,

 

Thank you for the speedy response.

 

The goal  is to be able to use pattern matching, or to write specific code that will modify a pattern so that it will be consistent with our other validation rules.

 

Something like,

 

Datum   = “ABC*,123”

pattern = “!0X’*’0X”

 

IF datum MATCHES pattern THEN CRT “Error: asterisk found”

 

Chris Long

RA Services

 

 


image001.jpg

José P. Junco Ivern

unread,
Jan 20, 2012, 12:05:26 PM1/20/12
to reality-...@googlegroups.com

One note of suggestion , with the INDEX function one has more flexibility in the sense that it doesn’t require the ‘searched sub-string’ to be in any specific pattern or position and after that one can use the CONVERT / CHANGE / …. functions to remove the ‘*’ from the string. If that is what this is all about.  Just ‘Food For Thought’.   Have A Nice Day.

image002.jpg
image003.jpg

Chris Long

unread,
Jan 20, 2012, 12:12:16 PM1/20/12
to reality-...@googlegroups.com

José,

 

I hadn’t really considered that.  Our validation scheme might have to be modified a bit.  That is a big help.

 

Thanks again.

 

Chris

image001.jpg
image002.jpg

Darren Wragg

unread,
Jan 20, 2012, 12:21:00 PM1/20/12
to reality-...@googlegroups.com
How about this?

IF XXX MATCHES("0X'*'0X") THEN CRT "FOUND AN ASTERIX"    

That should be true if a '*' is found anywhere in a string or on its own.

Regards
Darren Wragg
image002.jpg
image001.jpg

Darren Wragg

unread,
Jan 20, 2012, 12:26:01 PM1/20/12
to reality-...@googlegroups.com
I do of course mean "asterisk"   rather than the similar sounding cartoon character I typed by accident!
--


Darren Wragg
Application Development

T: 01353 650 900
E: dwr...@cromwells.co.uk
W: www.cromwells.co.uk

Cromwell Business Systems Ltd
King’s View House
3 Bartholomew’s Walk
Cambridgeshire Business Park
Ely, Cambridgeshire CB7 4EA

***Private and Confidential Notice***

The information contained in this e-mail is intended for the named recipient(s) only. It may contain privileged and confidential information and if you are not the intended recipient(s) you must not copy, distribute or take any action or reliance on it. If you have received this e-mail in error, please notify the sender immediately by using the e-mail address.



image002.jpg
image001.jpg

Chris Long

unread,
Jan 20, 2012, 12:31:33 PM1/20/12
to reality-...@googlegroups.com

Thanks Darren, and everyone else.

 

You’ve given me plenty to work with.  It seems like today I can’t think “out of the box.”

 

Chris Long

RA Services

 


image001.jpg
image002.jpg
Reply all
Reply to author
Forward
0 new messages