473,378 Members | 1,617 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,378 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 1404
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...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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
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
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?
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.