473,379 Members | 1,245 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,379 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 1790
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.