473,398 Members | 2,113 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,398 software developers and data experts.

RegX pattern required

Can anyone help me with a regx to match the values 1 to
6. No these could come in several formats and we only
want matches where there is a single number with no other
numbers next to it in the string, We could have an alpha
beside it on either side though

Examples of matches
1
2
3
4
5
6
1abc
abc2
1 abc
abc 1
1 +31651465867 (Where we would only want the 1)
+31651465867 1(Where we would only want the 1)

Examples of no matches
+61539759765
12 ksahflkah
Nov 20 '05 #1
1 1191
Try this one:

(?<=^(.*?\D)?)[1-6](?=(\D.*)?$)
Brian Davis
www.knowdotnet.com

"Glenn Wilson" <gw***@hotmail.com> wrote in message
news:04****************************@phx.gbl...
Can anyone help me with a regx to match the values 1 to
6. No these could come in several formats and we only
want matches where there is a single number with no other
numbers next to it in the string, We could have an alpha
beside it on either side though

Examples of matches
1
2
3
4
5
6
1abc
abc2
1 abc
abc 1
1 +31651465867 (Where we would only want the 1)
+31651465867 1(Where we would only want the 1)

Examples of no matches
+61539759765
12 ksahflkah

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Marc Pelletier | last post by:
Hello, I am still fairly new to CSharp and am trying to implement a singleton pattern. I found Jon Skeet's excellent page (http://www.yoda.arachsys.com/csharp/singleton.html), but am struggling...
12
by: FluffyCat | last post by:
New on November 28, 2005 for www.FluffyCat.com PHP 5 Design Pattern Examples - the Visitor Pattern. In the Visitor pattern, one class calls a function in another class and passes an instance of...
1
by: Jake Barnes | last post by:
This was working for me, and now it isn't, and I can't remember what i changed - the idea was to imitate the PHP command nl2br, which takes newlines and turns them into newlines plus BR tags. Does...
2
by: dongdong | last post by:
for example: re.sub('<a( +)+\s?>*</a>','',' asd ga<a target="_blank" href="http://www.sine.com" class="wordstyle"> asdgasdghae rha</a>') I wish to get the return value "asd ga asdgasdghae...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
5
by: pramodkh | last post by:
Hi All I am trying to match a pattern in a file and insert a line. If the pattern matches then insert a line before the matching pattern line. for example, I have the following content in a...
3
by: Cain | last post by:
A very simple regular expression test: var regx = /^\d+$/g; alert(regx.test("11") + ": " + regx.test("11")); And the output is "true: false". If I change to regx = new RegExp("^\\d+$",...
1
by: jain236 | last post by:
Hi i am trying to write regx for the time format HH:MM:SS in the below way /\d:\d0:\d/ but i could not get the desired output, can some one throw some light why and where it is going wrong?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.