Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-19-2012, 12:09 AM   PM User | #1
jordandap
New Coder

 
Join Date: Jul 2011
Posts: 44
Thanks: 5
Thanked 0 Times in 0 Posts
jordandap is an unknown quantity at this point
regular expresions?

Hi I have the following expression that I found using google (regex is the bane of my existence) and it searches for all math equations such as + * 1 / () ect

what I wish to do is grab all the values (numbers) out of the string in order and put inside the array "stackNumbers" and all the operations (in order) into another array "stackOperations" with an infinite find on the operations/numbers

but the tricky part I want to do with this regex is to have any string inside of a "" which would match "test1" or "te1st" but not "1test" and put this (in order) into the "stackNumbers" array but they have to be in order with the numbers also so if i had the following input

10+5+"var15"*55/"l33t"+5
"stackNumbers" would look like this "10,5,var15,55,l33t,5" and "stackOperations" would look like this "+,+,*,/,+"


heres the regex i have currently

"(([\\+\\-\\/\\*\\^]?)([(]*(([(]?(([+-]?\\d+[.,]?(\\d+)?)([e][+-]\\d+)?)[)]?)|([(]?value[)]?))[)]*)?(([(]*([(]?(([+-]?\\d+[.,]?(\\d+)?)([e][+-]\\d+)?)[)]?)|([(]?value[)]?))[)]*)?([\\+\\-\\/\\*\\^])([(]*(([(]?(([+-]?\\d+[.,]?(\\d+)?)([e][+-]\\d+)?)[)]?)|([(]?value[)]?))[)]*))+"
jordandap is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:58 PM.


Advertisement
Log in to turn off these ads.