Solved

Pattern Matching

Posted on 1998-09-10
2
204 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
This video discusses moving either the default database or any database to a new volume.

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now