Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking string for predefined format
Message
De
15/08/2000 04:32:45
 
 
À
15/08/2000 02:59:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00403485
Message ID:
00404831
Vues:
25
>>Sergey,
>>
>>Again, great for noticing. I understood this bug at home too, but your message was a reminder to me to fix it. I'll do it right now.
>>
>>Thanks again for your help. I noticed, you often use this technique, and I'll start too. I also will investigate "Ed's route"...
>>
>Out of general boredom:
>
>
oRegExp=CREATEOBJ('vbscript.regexp')
>oRegExp.Pattern = '\d{6}[A-Z]-[A-Z]\d{6}[A-Z]-[A-Z]\d{6}[A-Z]{2}-[A-Z]{2}\d{6}[A-Z]'
>? oRegExp.Test('012345A-B012345C-D012345EF-GH012345I')
>? oRegExp.Test('012345A-b012345C-D012345EF-GH012345I')
Oops, grabbed the wrong template, you're using 999999X-X999999X-X999999XX-XX999999X-XXXXXX - the following massize code change is needed:

oRegExp=CREATEOBJ('vbscript.regexp')
oRegExp.Pattern = '^\d{6}[A-Z]-[A-Z]\d{6}[A-Z]-[A-Z]\d{6}[A-Z]{2}-[A-Z]{2}\d{6}[A-Z]-[A-Z]{6}$'


You can be far more selective; for example, lets try an ISBN, 10 characters long, the first 9 are digits, but the last position could be 0-9 or "X"

oRegExp.Pattern = "\d{9}[0-9X]"

or how about 3 numbers of 1-4 digits in length, followed by a comma which might be followed with a space or might not:

oRegExp.Pattern = "\d{1,4},\s?\d{1,4},\s?\d{1,4}"

Let's change that to allow any number of blanks instead of 0 or 1:

oRegExp.Pattern = "\d{1,4},\s*\d{1,4},\s*\d{1,4}"

3 words at the start of a line, any case, composed of letters, with any amount of whitespace in between, and the end of the third word ending the string:

oRegExp.Pattern = '^[A-Za-z]+\s+[A-Za-z]+\s+[A-Za-z]+$'

Try this with "The quick brown", "The quick brown fox", " The quick brown" and "The quick brown"

A vowel, followed by 3-9 valid VFP 'name' characters:

oRegExp.Pattern = "^[AEIOU]\w{3,9}$"
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform