Jump to content

" No ending delimiter '^' found in " What Have I done ?


JChilds

Recommended Posts

I'm trying to use preg_match to retun all numbers that are between ID= and "

 

ie;

 

ID_1234567"

 

will retun

 

1234567

 

 

This is what i have used:

preg_match('^id_[-+]?\d+"$',
'input', $matches); 

 

But I keep getting the error

 

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /home/noexcuse/public_html/id.php on line 8

 

Can anyone please help me? This is driving me mad!

preg_match returns an array of matches.

 

use:

preg_match('/^id_[\d]+$/', 'input', $matches);

echo '<pre>' . print_r($matches, true) . '</pre>';

To see the matches returned from the expression.

 

Thanks. I'm still learning.

 

Now, with an input of id_1234567" I get an output of

Array
(
)

 

 

Here is exactly what I have

 

<?php


$input = $_POST["input"];

preg_match('/^id_[\d]+$/', 'input', $matches);

echo '<pre>' . print_r($matches, true) . '</pre>';


?>

 

I am probably just making some stupid beginner mistake :(

Are you wanting to match the quote after the numbers too:

id_1234567"

 

Also 'input' should be $input

 

<?php

$input = $_POST["input"];

preg_match('/^id_[\d]+"$/', $input, $matches);

echo '<pre>' . print_r($matches, true) . '</pre>';

?>

 

Are you wanting to match the quote after the numbers too:

id_1234567"

 

Also 'input' should be $input

 

<?php

$input = $_POST["input"];

preg_match('/^id_[\d]+"$/', $input, $matches);

echo '<pre>' . print_r($matches, true) . '</pre>';

?>

 

 

 

Thankyou.

 

Yes, the quote aswell.

 

There are about 200 lines of input similar to this (source of a page)

 

<td><input name="id_1523023" type="checkbox" />

 

 

Ok. Ill start right from the start.

 

I want to be able to paste the source code from a certain webpage into a form.

 

eg

 

<td><input name="id_1523023" type="checkbox" /> (about 200 lines though, all with different Id's)

 

I want it to tell me all the ID's in a simple list without the 'id_' or ' " '

 

Also (just to make things difficult) I'd love it to start from teh bottom of the page. Or re-arange the ID's the opposite way they were found.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.