Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Simple regular expressions question

Posted on 2007-04-07
2
Medium Priority
?
202 Views
Last Modified: 2013-12-12
Hello,

starting from a good base knowledge of regular expressions, I would like to know how to use them in Php.
Basically, I have a very simple SQL query structured like this:

SELECT field1, field2, ... , fieldN FROM tableX WHERE [conditions]

I would like to take this string and put the various select fields in an array of size (N - 1) which in the end will contain the various (field1, field2, ... , fieldN).

If you just show me how to do, I think I will be able to extrapolate the mechanism from your answer.
Thanks in advance.
0
Comment
Question by:Emanuele_Ciriachi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
Cornelia Yoder earned 750 total points
ID: 18869970
You might consider working with explode instead of regular expressions, it's much easier.  You'd only have to deal with spaces and commas separating your words.

Start by removing the commas with a regular expression or any other simple means, then use

$array = explode(" ",$string);

http://us.php.net/manual/en/function.explode.php
0
 
LVL 1

Author Comment

by:Emanuele_Ciriachi
ID: 18871966
Worked fine with explode(), thanks.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…
Suggested Courses

618 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