Solved

Pattern Matching

Posted on 1998-09-10
2
214 Views
Last Modified: 2010-03-05
What is the correct syntax for performing the following functions?

a.)  I have a variable ($MyVariable) with a string as its value. The string would be something like this:  "sometext||some-other-text".  I want to return just the text to the LEFT of the "||" (or any delimiter).

b.)Taking that one step further, if $MyVariable = "sometext||some-other-text::even-more-text".  I need functions to extract each portion of the string.
0
Comment
Question by:IsleOfView
2 Comments
 
LVL 1

Accepted Solution

by:
stormerider earned 30 total points
ID: 1204796
a.) Hmmm, Pier Xanthony?

b.)

($a, $b, $c) = split(/|/, $MyVariable);
This is assuming you meant there were three variable fields, else:
($a, $b) = split(/||/, $MyVariable);

0
 

Author Comment

by:IsleOfView
ID: 1204797
Good answer--that worked great, except that you need to escape the |'s with "\".  Thanks!
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 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