473,387 Members | 3,810 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,387 software developers and data experts.

Simplifying a regular expression using backreferences

3
hi, I'm a regex beginer and I want to know if with backreferences \1 I can reduce the ip test regex that I found on a web site :
Expand|Select|Wrap|Line Numbers
  1. \b (25[0-5] |2 [0-4] [0-9]| [01]? [0-9][0-9]?)\. (25[0-5] |2 [0-4] [0-9]| [01]? [0-9][0-9]?)\. (25[0-5] |2 [0-4] [0-9]| [01]? [0-9][0-9]?)\. (25[0-5] |2 [0-4] [0-9]| [01]? [0-9][0-9]?)\b
By something like that :
Expand|Select|Wrap|Line Numbers
  1.  \b (25[0-5] |2 [0-4] [0-9]| [01]? [0-9][0-9]?)\.)\1\1 (25[0-5] |2 [0-4] [0-9]| [01]? [0-9][0-9]?)\b?
I ask that in aim of understand backreferences thank you for answer me.

(@^_^@)
Sep 12 '07 #1
4 1406
pbmods
5,821 Expert 4TB
Heya, Ten. Welcome to TSDN!

Please use CODE tags when posting source code:

[CODE]
Source code goes here.
[/CODE]
Sep 12 '07 #2
TenTen
3
ok, sorry for that ...
Sep 17 '07 #3
pbmods
5,821 Expert 4TB
Heya, Ten.

That should work, assuming that you want the first three octets to be identical. Backreferences match the result of the rule, not the rule itself.
Sep 17 '07 #4
TenTen
3
ok if I understand exactly what you say, if the first octet is 175 with backreference the second and third term are 175 too ...

this is not what I want but at this time backreference were easier now

thank you for the help

cya
Oct 3 '07 #5

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

Similar topics

3
by: Vibha Tripathi | last post by:
Hi Folks, I put a Regular Expression question on this list a couple days ago. I would like to rephrase my question as below: In the Python re.sub(regex, replacement, subject)...
1
by: jnc | last post by:
I was wondering whether anyone could help me out splitting out the following string (an excel formula) using a regular expression. What I would like to be able to do is get the dependency paths,...
4
by: JackRazz | last post by:
Could someone give me a very simple regular expression for Visual Studio's search/replace using backreferences saving portions of the match as \1 or $1 or whatever. I want to use something I can...
7
by: Tizzah | last post by:
What is wrong with that? regex = /^(http|https):\/\/+({1}+)*\.{2,5}(({1,5})?\/.*)?$/ if(field.hpage.value != regex.test(field.hpage.value)){ alert("Bad Homepage") field.hpage.focus()...
19
by: Davy | last post by:
Hi all, I am a C/C++/Perl user and want to switch to Python (I found Python is more similar to C). Does Python support robust regular expression like Perl? And Python and Perl's File...
5
by: shawnmkramer | last post by:
Anyone every heard of the Regex.IsMatch and Regex.Match methods just hanging and eventually getting a message "Requested Service not found"? I have the following pattern: ^(?<OrgCity>(+)+),...
8
by: cokofreedom | last post by:
I was reading up on this site http://www.noulakaz.net/weblog/ 2007/03/18/a-regular-expression-to-check-for-prime-numbers/] of an interesting way to work out prime numbers using Regular Expression....
47
by: Henning_Thornblad | last post by:
What can be the cause of the large difference between re.search and grep? This script takes about 5 min to run on my computer: #!/usr/bin/env python import re row="" for a in range(156000):...
8
by: Uwe Schmitt | last post by:
Hi, Is anobody aware of this post: http://swtch.com/~rsc/regexp/regexp1.html ? Are there any plans to speed up Pythons regular expression module ? Or is the example in this artricle too...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.