Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Extract a string

by scarus (Novice)
on Sep 04, 2008 at 10:24 UTC ( #708984=perlquestion: print w/replies, xml ) Need Help??

scarus has asked for the wisdom of the Perl Monks concerning the following question:

How can the string "USERs/User_01/user_01.config" can be extracted from the follwoing?
<include>$CONFIGURATION_PATH$/USERs/user_01/user_01.config</include>

Replies are listed 'Best First'.
Re: Extract a string
by ikegami (Patriarch) on Sep 04, 2008 at 10:31 UTC

    I presume what you want is to determine what's between the include tags, ignoring the leading '$CONFIGURATION_PATH$/'.

    my ($desired) = $original =~ m{^<include>\$CONFIGURATION_PATH\$/(.*)</include>$};

    Update: Removed stray slash in regexp.

Re: Extract a string
by Grey Fox (Chaplain) on Sep 04, 2008 at 14:13 UTC
Re: Extract a string
by eff_i_g (Curate) on Sep 04, 2008 at 16:11 UTC
    Is this truly in XML?
    Will there be multiple include pairs (elements)?
Re: Extract a string
by johndageek (Hermit) on Sep 05, 2008 at 19:07 UTC
    Jst for fun and since I know compuers can be a wee bit picky, your string "USERs/User_01/user_01.config" will never be fouind in the string "<include>$CONFIGURATION_PATH$/USERs/user_01/user_01.config</include>"

    User_01 and user_01 do not match due to case difference.

    use uc() on both sides of the strnig and attempt a compare.

    Enjoy!
    Dageek

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://708984]
Approved by wfsp
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2022-10-01 08:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (126 votes). Check out past polls.

    Notices?