CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Need to write a regular expression.

 



sgurumukhi
New User

Apr 26, 2011, 11:48 PM

Post #1 of 2 (1966 views)
Need to write a regular expression. Can't Post

I want to write a regular expression for the below cose.

Here is my code.

<ResourceCompile>
<PreprocessorDefinitions>INTL_US;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
<AdditionalIncludeDirectories>res\us;res;..\dlls;..\qw;..\ictls;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ResourceOutputFileName>$(IntDir)$(ProjectName).res</ResourceOutputFileName>
</ResourceCompile>

According to me output is:

$content =~ s/(<ResourceCompile>(.*?:\s|\n)(<PreprocessorDefinitions>)([^>]*)(\<)(?:\s|\n)*(<AdditionalIncludeDirectories>)([^>]*\m)(\<\/)(?:\s|\n\<\/)

I am not getting output for <AdditionalIncludeDirectories>

If I do $content =~ s/(<AdditionalIncludeDirectories>)([^>]*)(\<\/) , o/p is correct.

Need to know the cause and output for it.

Any help in this regards will really help me.


miller
User

Apr 27, 2011, 12:03 AM

Post #2 of 2 (1965 views)
Re: [sgurumukhi] Need to write a regular expression. [In reply to] Can't Post

use XML::Simple


Code
use XML::Simple; 

use strict;

my $data = do {local $/; <DATA>};

my $xml = XMLin($data);

use Data::Dumper;
print Dumper($xml);

__DATA__
<ResourceCompile>
<PreprocessorDefinitions>INTL_US;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
<AdditionalIncludeDirectories>res\us;res;..\dlls;..\qw;..\ictls;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ResourceOutputFileName>$(IntDir)$(ProjectName).res</ResourceOutputFileName>
</ResourceCompile>



(This post was edited by miller on Apr 27, 2011, 12:04 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives