Solved

Regular Expression for matching Hex a0 two capital letters then a0

Posted on 2008-10-31
4
1,372 Views
Last Modified: 2012-05-05
Trying to write a Perl Regular to accomplish the following given:

LAKE ST LOUIS MO 63367­1348

the spaces are not normal HEX 20, but are in fact HEX A0...

I am trying to parse this type of string to City, State, Zip fields...

The state isn't always MO this is just an example.

I suck at complicated regular expressions.

I tried /\xa0[A-Z][A-Z]\xa0/   but doesn't seem to work right.

Any help greatly appreciated!
Dan


0
Comment
Question by:dyoung520
  • 2
4 Comments
 
LVL 27

Expert Comment

by:ddrudik
Comment Utility
You shuld be able to match a non-breaking space ascii 160 hex \xa0 with the pattern as shown.

In php:
<?php
echo preg_match('/\xa0/',chr(160)) ? "found non-breaking space" : "not found";
?>

Is it possible those are \x20 instead, here's how your string appears in regex (as pasted above):
^LAKE\x20ST\x20LOUIS\x20MO\x2063367\xC2\xAD1348$
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
Comment Utility
$_ = "LAKE ST LOUIS\xa0MO\xa063367­1348";
print /(\xa0[A-Z][A-Z]\xa0)/
 MO
0
 

Author Comment

by:dyoung520
Comment Utility
Really the problem is I'm just an idiot!!!

LAKE\xa0ST\xa0LOUIS\xa0MO\xa063367­1348

That's how the string looks...  Why was I having a problem??

Because "ST" matches - see I'm an Idiot :-)

Thanks for your help... I still would not have seen my error without seeing your posts!

0
 

Author Closing Comment

by:dyoung520
Comment Utility
You proved to me I'm an idiot!  I've been saying this for years and people around me don't believe me... Thanks Again!!!!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now