Solved

Regex help

Posted on 2005-04-21
2
166 Views
Last Modified: 2010-03-05
Ok, new to regex and trying to figure this one out:

sum(one+two+three+four)

I want to get matches for one,two,three,four

Thanks.
0
Comment
Question by:lrr81765
2 Comments
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
You want to capture the matches?

@matches = /(one).(two).(three).(four)/;

Or to make it more generic

@matches = /\((\w+)\+(\w+)\+(\w+)\+(\w+)\)/;

0
 
LVL 84

Accepted Solution

by:
ozo earned 250 total points
Comment Utility
$_ = 'sum(one+two+three+four)';
@matches = /(\w+)(?=[+)])/g;
print join",",@matches;
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

12 Experts available now in Live!

Get 1:1 Help Now