Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

RegEx question

$
0
0

Can someone tell me why this expression does not produce a match with one space at the end:

$MyPattern = '^(5[1-5]\d{14})|(5[1-5]\d{2}[-| ]\d{4}[-| ]\d{4}[-| ]\d{4})$' 
$MyString = 'MC1 5111-1234-1234-1234'"Why this string '$MyString' matches: $($mystring -match $mypat)"
$MyString = 'MC1 5111-1234-1234-1234 '"but this string '$MyString' does not: $($mystring -match $mypat)"


Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable)


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>