LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-04-2014, 09:58 PM   #1
divyashree
Senior Member
 
Registered: Apr 2007
Location: Bangalore, India
Distribution: RHEL,SuSE,CentOS,Fedora,Ubuntu
Posts: 1,386

Rep: Reputation: 135Reputation: 135
parsing string with perl regular expression


I have two strings like below and want to match them with perl regex :
Code:
(\w+[.\d]+)

PHP Code:
Status.1

LocalAddress.129.221.5.33 
The regex is matching the second one but not the 1st one, but it should match. Can anyone help me with this ?
 
Old 03-04-2014, 11:55 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
As you have marked this as SOLVED, would you please explain what the solution is / was?
 
Old 03-05-2014, 02:53 AM   #3
divyashree
Senior Member
 
Registered: Apr 2007
Location: Bangalore, India
Distribution: RHEL,SuSE,CentOS,Fedora,Ubuntu
Posts: 1,386

Original Poster
Rep: Reputation: 135Reputation: 135
Quote:
Originally Posted by grail View Post
As you have marked this as SOLVED, would you please explain what the solution is / was?
Hi, actually the regex was matching both strings, I was in a hurry and gave the wrong input and got the wrong output.
 
Old 03-05-2014, 05:40 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
ahhh ... cause I was unable to match your suggested results ... now I see why
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl - regular expression to match variable number of digits after string kcleveland Programming 4 12-08-2011 04:46 AM
How can awk search a string without using regular expression? 915086731 Programming 8 09-07-2011 10:07 PM
Regular expression to match a valid URL string vharishankar Programming 13 07-21-2005 09:17 PM
regular expression for parsing html tags Bert Linux - Software 3 10-14-2002 04:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration