Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Patternmatching IPaddresses

by BrowserUk (Pope)
on Jun 21, 2013 at 22:47 UTC ( #1040233=note: print w/ replies, xml ) Need Help??


in reply to Patternmatching IPaddresses

I want the first 2 octets of other string should also be X and X How to do that?

Your first step would be to remove the ^ anchoring your regex to the start of the line but that will cause every pair of numbers separated by a dot, (actually, given your regex, any character, you should escape the '.'), which would be all of them result in in everything becoming 'xx.xx.xx.xx';

So you need to ensure that only the first pair of each quad get modified, so try: s/(?<![0-9.])\d+\.\d+/X.X/g;


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: Patternmatching IPaddresses
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040233]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2015-07-01 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (21 votes), past polls