active perl regex

Hi
I have this string which I need to extract the bold text from it using regex in active perl.
the regex I include is not cutting it. pls. help. thx

Breakout Trade: SELL EUR/JPY @ 101.42 Stop @ 101.77 Target #1 @ 101.17 Target #2 @ 100.97 Target #3 @ 100.82
if ($body =~m{.+?(buy|sell)\s+(.+?)\s+@\s+([\d.]+)\s+stop.*?([\d.]+).+?@\s([\d.]+).+?@\s([\d.]+).+?@\s([\d.]+)}ismxg){
						push @entries, {
							action => $1,
							cur    => $2,
							price  => $3,
							sl     => $4,
							t1     => $5,
							t2     => $6,
							t3     => $7,
						};

Open in new window

samjAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert SchuttSoftware EngineerCommented:
sometimes \s has a + other times not, so if there are several spaces it will fail.

I tried it as shown above (with 1 space in between all words/numbers), printed out $1 etc, and they are ok.

If this is not it, maybe the problem is in the push or the following part where you process @entries?
0
käµfm³d 👽Commented:
Try this version:

if ($body =~m{(BUY|SELL) ([^@ ]+) @ ([\d.]+) [^@]* @ ([\d.]+) [^@]* @ ([\d.]+) [^@]* @ ([\d.]+) [^@]* @ ([\d.]+)}i){

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
samjAuthor Commented:
I tried fixing the \s to \s+ for no avail.
I tried the code supplied by kaufmed for no avail.

here is the exact data
Breakout Trade: SELL EUR/JPY  101.42 Stop  101.77 Target #1  101.17 Target #2  100.97 Target #3
 100.82

Open in new window

0
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

käµfm³d 👽Commented:
Where did the @ symbols go?
0
samjAuthor Commented:
it has been removed in an earlier code line.
$body=~s/@//g;
I now have this

.+?(buy|sell)\s+(.+?)\s+([\d.]+).+?([\d.]+).+?([\d.]+).+?([\d.]+).+?([\d.]+)

which matches but it does not save the whole number in $5 and $7
0
samjAuthor Commented:
I ended up doing this which worked.
$body=~s/@|Target\s+#\d\s+@//g; 
if ($body =~m{.+?(buy|sell)\s+(.+?)\s+([\d.]+).+?([\d.]+).+?([\d.]+).+?([\d.]+).+?([\d.]+)}ismxg){

Open in new window

0
ozoCommented:
In absence of the @ you'd need some other way to specify what to skip over.  e.g.

/.+?(buy|sell)\s+(.+?)\s+([\d.]+).+?([\d.]+).+?\#1.*?([\d.]+).+?\#2.*?([\d.]+).+?\#3.*?([\d.]+)/ismxg
0
samjAuthor Commented:
ozo:
this is almost there, it did not skip over the @  in "EUR/JPY @"
0
ozoCommented:
You just told us that the exact data to be matched was
Breakout Trade: SELL EUR/JPY  101.42 Stop  101.77 Target #1  101.17 Target #2  100.97 Target #3
 100.82

Open in new window

with no @

Breakout Trade: SELL EUR/JPY  101.42 Stop  101.77 Target #1  101.17 Target #2  100.97 Target #3
 100.82

Open in new window

0
samjAuthor Commented:
sorry Ozo. it is my bad. here is the exact data.


Breakout Trade: SELL EUR/JPY @ 101.42 Stop @ 101.77 Target #1 @ 101.17 Target #2 @ 100.97 Target #3
@ 100.82

Open in new window

0
samjAuthor Commented:
thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.