Solved

Regular Expression for matching Hex a0 two capital letters then a0

Posted on 2008-10-31
4
1,392 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Expert Comment

by:ddrudik
ID: 22852825
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
ID: 22852890
$_ = "LAKE ST LOUIS\xa0MO\xa063367­1348";
print /(\xa0[A-Z][A-Z]\xa0)/
 MO
0
 

Author Comment

by:dyoung520
ID: 22853326
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
ID: 31512149
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
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…
Six Sigma Control Plans

696 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