Solved

Simple regular expressions question

Posted on 2007-04-07
2
198 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 250 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Curl Problem 10 73
JSON decode 5 43
php output utf-8 problem 6 50
MySQL - Adding an incremented value to a duplicate string 30 51
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

739 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