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!

Link to comment
Share on other sites

Use:

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

 

Thanks for the speedy reply.

 

When I use

 

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

 

With an input of id_1234567

 

I just get an output of "Array" :S

Link to comment
Share on other sites

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 :(

Link to comment
Share on other sites

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>';

?>

 

Link to comment
Share on other sites

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" />

 

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.