?
Solved

pattern matching

Posted on 2003-03-25
6
Medium Priority
?
221 Views
Last Modified: 2010-03-05

Hi
Below is text file...
Please help me grepping out the text between the tags <LOC> and </LOC>.

<LINE><ADM>DOLNOSLASKIE</ADM><LOC>BARDO</LOC><LOC1>OPOLNICA</LOC1><POCO>57-256</POCO><TYPE>Old
Name</TYPE><ADMSYN>WALBRZYSKIE<TYPE>OldName</TYPE></ADMSYN></LINE>
<LINE><ADM>DOLNOSLASKIE</ADM><LOC>BARKOWO K. MILICZA</LOC><LOC1>BARKOWO</LOC1><POCO>55-143</PO
CO></LINE>
<LINE><ADM>DOLNOSLASKIE</ADM><LOC>BARKOWO K. MILICZA</LOC><LOC1>BARKóWKO</LOC1><POCO>55-143</P
OCO></LINE>
<LINE><ADM>DOLNOSLASKIE</ADM><LOC>BARKOWO K. MILICZA</LOC><LOC1>KêDZIE</LOC1><POCO>55-143</POC
O></LINE>


waiting for a favourable reply

Regards
Biju Pillai
0
Comment
Question by:pillaib
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Expert Comment

by:prady_21
ID: 8201235

This should work

if ( /<LOC>(.*)<\/LOC>/ ) {
      print "$1\n";
}

0
 
LVL 84

Expert Comment

by:ozo
ID: 8201306
while( /<LOC>(.*?)<\/LOC>/g ){
     print "$1\n";
}
0
 
LVL 48

Expert Comment

by:Tintin
ID: 8206912
or as a single line

print "$1\n" while (/<LOC>(.*?)<VLOC>/);
0
 
LVL 1

Accepted Solution

by:
hemaraj123 earned 100 total points
ID: 8215864
I will agree with all the above three, but whenever you have an enter mark in between <LOC> and </LOC>, then all the above three will fail, for that below code will work for all.

while (/<LOC>(.*?)<\/LOC>/s) {
  print $1."\n";
}
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9705895
Nothing has happened on this question in over 7 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by hemaraj123.

Please post any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question