Advertisement

12.23.2007 at 01:24PM PST, ID: 23040883
[x]
Attachment Details

Parsing String Using Functions and Regular Expressions

Asked by idadan in Ruby Scripting Language

Tags: , , ,

Basically I have one string that I need to break out into seperate parts.  I'm still not great with ruby functions so just need a little help.

I start with a string that looks like the following:
SEARCH_TERM(S) CITY,STATE

I need to break apart all these into three variables.
1. SEARCH_TERMS(S)
2. CITY
3. STATE

Note there is a space between last search item and the city.

Thanks for any help!Start Free Trial
1:
2:
3:
4:
5:
search_parts = params[:search].split(',') # splits everything and the state
 
state = search_parts[1] #assigns state from prev. line
 
# need code here to break apart the rest.
[+][-]12.23.2007 at 02:21PM PST, ID: 20522771

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Ruby Scripting Language
Tags: ruby, string, parse, using
Sign Up Now!
Solution Provided By: wesgarrison
Participating Experts: 3
Solution Grade: A
 
 
[+][-]12.24.2007 at 01:49AM PST, ID: 20524038

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.24.2007 at 03:37AM PST, ID: 20524296

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.08.2008 at 02:45PM PST, ID: 20613794

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.08.2008 at 04:02PM PST, ID: 20614283

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628