473,322 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Regex challange...kinda :-)

Kelicula
176 Expert 100+
I have a strange case, that has just stumped me.
I am trying to make sure that if someone's name starts with just one character (between "space" and "tilde") OR it starts with one letter followed by a "dot" it's no good BUT if it is one letter followed by a dot and another character it's OK.

Meaning these names are ok, J.D. or TJ.

But these are BAD J or T.

Here's what I have:

Expand|Select|Wrap|Line Numbers
  1. my $name = "J.D. McKinney";
  2.  
  3. if ($name =~ m{ \A (?: [\x20-\x7E]{1}\.?\b\W ) }xms){
  4.     print "matched";
  5.  
  6. }
  7. else{
  8.     print "no match";
  9. }
  10.  
What am I missing?????

It prints "matched".

How can "the beginning of the line followed by any character from space to tilde once, followed by 1 or 0 dots followed by a word boundary followed by a NON WORD character" match THAT string!!???

I can't see what is wrong..

Any help would be MUCH appreciated!!
Feb 26 '15 #1
1 1788
Kelicula
176 Expert 100+
OK, no replies, well just for the record I found out what it was I was choosing the same delimiter for my regular expression as is used in the repetitive quantifier therefore on the closing bracket of the 1 repetitive qualifier it was closing the regular expression I changed my delimiter to a single quote and it worked perfectly.
Mar 6 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mark | last post by:
hello! I'm trying to use the POSIX regex syntax in PHP, and having a bit of trouble with word boundary separators. The basic syntax i have seen in the various tutorials i have read over the...
4
by: DH | last post by:
I need to parse some HTML tags and display the style classes, and have it partly working, but need some regex / preg_match advise. If the tag is <td class="red" colspan="1"> I can display...
2
by: .NET Developer | last post by:
Hello, I'm trying to write a RegEx that will find all occurances of a particular type of HTML anchor <a> element in a big block of HTML. Here are the pattern requirements - they consist of certain...
9
by: taylorjonl | last post by:
I am having a problem matching some text. It is a very simple pattern but it doesn't seem to work. Here goes. <td*>.*?</td> That is the pattern, it should match any <td></td> pair. Here is...
15
by: Kay Schluehr | last post by:
I have a list of strings ls = and want to create a regular expression sx from it, such that sx.match(s) yields a SRE_Match object when s starts with an s_i for one i in . There might be...
6
by: Extremest | last post by:
I have a huge regex setup going on. If I don't do each one by itself instead of all in one it won't work for. Also would like to know if there is a faster way tried to use string.replace with all...
7
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward...
3
by: aspineux | last post by:
My goal is to write a parser for these imaginary string from the SMTP protocol, regarding RFC 821 and 1869. I'm a little flexible with the BNF from these RFC :-) Any comment ? tests= def...
15
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
5
by: DbZ | last post by:
Hi - i'm new to the regex thing - and trying to learn it to myself - Can someone please explain to me what the following line does - value.replace(/\s+$/g,"") I can kinda figure out its...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.