Connecting Tech Pros Worldwide Help | Site Map

need help on perl reqex

Newbie
 
Join Date: Nov 2006
Posts: 4
#1: Nov 16 '06
Hi,

I'm new to perl. Can someone help me on the perl regex please!
Scenario:

I have a log file read in a variable $error which looks like:

<request type="update" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PortalConfig_1.2.xs d">
<status element="[url-mapping-context _C_0G3UNU10SD0GHOSD_TFR]" result="failed">
<message>com.ibm.wps.command.xml.XmlCommandExcepti on: XMLC0025E: The Resource was not found in the portal, either because it does not exist or because you have not specified an identifying attribute in the XML input. [url-mapping-context _C_0G3UNU10SD0GHOSD_TFR]</message>
</status>
</request>

XMLACCESS failed for importing /nas/app/PortalServer/teamsite/xml/wps/url_Mapping/deleted/C_0G3UNU10SD0GHOSD_TFR_makhtar_page1/C_0G3UNU10SD0GHOSD_TFS_urlmapping_makhtar_page2.xm l';

I want to do pattern matching based on the following:
1) if (<status element="[url-mapping-context) && ( /deleted/ i.e, path has deleted folder)
then return 0;
Member
 
Join Date: Nov 2006
Posts: 83
#2: Nov 16 '06

re: need help on perl reqex


Quote:

Originally Posted by akhtar

Can someone help me on the perl regex please!

<data example snipped>

Quote:

Originally Posted by akhtar

I want to do pattern matching based on the following:
1) if (<status element="[url-mapping-context) && ( /deleted/ i.e, path has deleted folder)
then return 0;

Can you please show us what you have tried?

Btw, why do you want a regex? Have you considered to use the index() function?
Newbie
 
Join Date: Nov 2006
Posts: 4
#3: Nov 16 '06

re: need help on perl reqex


I have so far tried, my first match works but second one doesn't:

if (($error_log_text =~ m/<status element=\"\[url-mapping-context/) && ($error_log_text =~ m/url_Mapping\/\deleted/)){
print "match found \n";
}else {
print "match not found\n";
}
Member
 
Join Date: Nov 2006
Posts: 83
#4: Nov 16 '06

re: need help on perl reqex


Try without that backslash:
Expand|Select|Wrap|Line Numbers
  1. && ($error_log_text =~ m/url_Mapping\/\deleted/)
  2. --------------------------------------^
Newbie
 
Join Date: Nov 2006
Posts: 4
#5: Nov 16 '06

re: need help on perl reqex


cool! thanks! it works!
Newbie
 
Join Date: Nov 2006
Posts: 4
#6: Nov 16 '06

re: need help on perl reqex


What if I have to match
url-mapping-context
ignore the rest of next chars but match
result="failed"
Member
 
Join Date: Nov 2006
Posts: 83
#7: Nov 16 '06

re: need help on perl reqex


Want to learn about regular expressions in Perl? Then read about regular expressions in Perl.

http://perldoc.perl.org/perlretut.html
Reply


Similar Perl bytes