News:

Wondering if this will always be free?  See why free is better.

Main Menu

Help fixing up Regex

Started by Shoeb Omar, September 09, 2004, 08:18:04 PM

Previous topic - Next topic

Shoeb Omar

Separate thread form AMA's cause I don't want to confuse things.

I'm trying to run a regex for replacing stuff in my php editor, and I just can't get my regex right.  I'm tyring to match something as follows:

bx_db_insert($bx_table_prefix."_jobapply","applyid,jobid,resumeid,compid,persid,apply_date,resume_view,apply_type,comp_status,pers_status","'','".$company_result['jobid']."','".$contact_result['resumeid']."','".$company_result['compid']."','".$contact_result['persid']."',DATE_ADD(NOW(), interval ".TIMEZONE_OFFSET." HOUR),'0','apply','new','new'");

but I can't get the comma diffrentiation right (I wanna match each of the three parameters. The easy version looks like:

bx_db_insert($table,$fields,$values)

and with that my ****** regex works:

bx_db_insert\(([^,]*),([^,]*),([^,\)]*)\)

but the [^,] isn't specific enough for the mass one's liek above when there's multiple commas.

Any ideas?

roboter88

#1
Mybe this is useful?

http://www.regular-expressions.info/examples.html

sry :P i just reading its only html, hehe


bb      To be
|       or
[^      not
{2}     to
b]      be


\d = [0-9]
\D = [^0-9]
   = [^\d]
\w = [0-9a-zA-Z_]
   = [\da-zA-Z_]
\W = [^0-9a-zA-Z_]
   = [^\da-zA-Z_]
   = [^\w]
\s = [ \n\t\r\v\f]
\S = [^ \n\t\r\v\f]
   = [^\s]
.  = [^\n] (ohne Modifier s)
.  = [\x00-\xFF] ,also alle Zeichen (mit Modifier s)

Shoeb Omar


Parham

shoeb, out of the above regex what are $1, $2, $3 supposed to match?

Shoeb Omar

$1 = $table
$2= $fields
$3 = $values

[Unknown]

You're going to need a specific subexpression... ugh.

-[Unknown]

Parham

Quote from: Shoeb Omar on September 09, 2004, 10:17:40 PM
$1 = $table
$2= $fields
$3 = $values

i meant in the specific example you gave above... it's a little hard to see where to start and stop.

Shoeb Omar

Quote from: Parham on September 09, 2004, 11:35:47 PM
Quote from: Shoeb Omar on September 09, 2004, 10:17:40 PM
$1 = $table
$2= $fields
$3 = $values

i meant in the specific example you gave above... it's a little hard to see where to start and stop.

lmao, it's hard for me to find too.. It's part of this script I'm rewriting (guess why I'm rewriting it!)

@Uncle Known:

Quote
You're going to need a specific subexpression... ugh.

I'm guessing that's a pain? :P

- Shoeb

(There's 76 of these and I wasn't looking forward to doing them manually :P)

Parham

the problem is that there is no clear beginning and ending (with single quotes, or double quotes, or spaces).  for any regex to work, there'd need to be some uniformity.

Advertisement: