Raised This Month: $ Target: $400
 0% 

Regex - Help with loop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-22-2014 , 17:10   Re: Regex - Help with loop
Reply With Quote #1

The second parameter decides match. 0 is the general match and 1-X is subgroups.
I did some testing but I couldn't get it to work.
The problem is that he doesn't know the amount of delimiters.
__________________
Black Rose is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-22-2014 , 17:15   Re: Regex - Help with loop
Reply With Quote #2

Quote:
Originally Posted by Black Rose View Post
The problem is that he doesn't know the amount of delimiters.
Then Regex should NOT be used if there is a better alternative like explode. I.e. use the right tool for the job.
__________________

Last edited by fysiks; 06-22-2014 at 17:15.
fysiks is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-22-2014 , 19:31   Re: Regex - Help with loop
Reply With Quote #3

While I agree with that explode requires an upper limit in the form of a hardcoded 2d array.
Much better to just loop through the string directly.

But the XY-problem prevents any good advice really.
__________________
Black Rose is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-22-2014 , 21:03   Re: Regex - Help with loop
Reply With Quote #4

Quote:
Originally Posted by Black Rose View Post
While I agree with that explode requires an upper limit in the form of a hardcoded 2d array.
Much better to just loop through the string directly.

But the XY-problem prevents any good advice really.
I agree that this in an XY-problem. However, based on the original post, I think strtok is actually the best.

@OP, You need to give us more information about what you are actually trying to do because you already have the best method, strtok() (regex is NOT a good tool to use for what you have asked; you don't need a chainsaw to slice bread). Until you do this, it seems you have your final answer from the community.
__________________
fysiks is offline
...
Junior Member
Join Date: Jun 2014
Old 06-23-2014 , 12:16   Re: Regex - Help with loop
Reply With Quote #5

Anyways will stick to strtok method
... is offline
Reply



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 -4. The time now is 21:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode