bruce wrote:
> hi...
>
> trying to figure out the best approach to using preg_match to extract the
> number from the follwing type of line...
>
> " 131646 sometext follows.."
>
> basically, i want to extract the number, without the text, but i have to be
> able to match on the "text"
>
> i've b
preg_match('/^([0-9]+) (.)+/',$sString,$aMatches);
Matches will be 1 => the number ; 2 => the text. The expression only matches
if there is any character after the space. Not necessarily text, it might
be another number or special characters
2009/2/6 bruce
> hi...
>
> trying to figure out the
Nicklas Bondesson wrote:
How do I find an exact match of a string with preg_match?
Example:
String1: www.test.com/
String2: www.test.com/somepage.php?param1=true
How do you write the regexp to only return String1 and not String2 when you
match against "www.test.com" ??
I've heard == works well. Or
* Thus wrote Nicklas Bondesson:
> Actually I think I got it working now (without escaping the ".").
cause . is any character
wwwatestbcom will get matched as well.
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our m
amp;pos=0&view=a&head=b> ]
Sent: den 18 augusti 2004 18:02
To: "Nicklas Bondesson"
Cc: [EMAIL PROTECTED]
<http://uk.f251.mail.yahoo.com/ym/[EMAIL PROTECTED]&YY=19
751&order=down&sort=date&pos=0&view=a&head=b>
Subject: Re:
---
Is it clever to use word boundary here? "/b"?
Nicke
From: John Legg [mailto:[EMAIL PROTECTED]
Sent: den 18 augusti 2004 18:02
To: "Nicklas Bondesson"
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] preg_match question
Try using a p
Is it clever to use word boundary here? "/b"?
Nicke
From: John Legg [mailto:[EMAIL PROTECTED]
Sent: den 18 augusti 2004 18:02
To: "Nicklas Bondesson"
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] preg_match question
Try using a pattern
On Wed, 18 Aug 2004 17:16:24 +0200, Nicklas Bondesson <[EMAIL PROTECTED]> wrote:
> Hello,
>
> How do I find an exact match of a string with preg_match?
>
> Example:
>
> String1: www.test.com/
> String2: www.test.com/somepage.php?param1=true
>
> How do you write the regexp to only return String
Try using a pattern set to the following:
$pattern = "/^www.test.com$/";
and refer to: http://uk.php.net/manual/en/reference.pcre.pattern.syntax.php
Rgds
John
---
Hello,
How do I find an exact match of a string with preg_match?
Example:
String1: www.test.com/
String2: www.test.com/somepa
Thank you both Jason and Curt...
Looks like I was pretty close...
In fact, I found a fault in my logic, too, that meant only some but not all
instances of $element were being validated, even after i got the preg
function right! But it's all working great now.
- john
> >
> > As John has previousl
* Thus wrote Jason Wong:
> On Wednesday 21 July 2004 10:04, John Van Pelt wrote:
>
> > function isWord($element) {
> > return !preg_match ("/[^A-Za-z\-\(\)\s]/", $element);
> > }
> >
> > I want to test the string $element and make sure that it contains nothing
> > but:
> > - characters A-Z
>
On Wednesday 21 July 2004 10:04, John Van Pelt wrote:
> function isWord($element) {
> return !preg_match ("/[^A-Za-z\-\(\)\s]/", $element);
> }
>
> I want to test the string $element and make sure that it contains nothing
> but:
> - characters A-Z
> - characters a-z
> - hyphen
> -
Great quote Jeroen.
>>Always code as if the guy who ends up maintaining your code will be a violent
>>psychopath who knows where you live.
>> -- Martin Golding
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> Is there a preg to find a "?" in a string since a "?" is used for
> calculations as I see it.
>
You just need to escape it with a backslash, e.g. \?
Good luck,
Marco
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
al Message-
From: Marco Tabini [mailto:[EMAIL PROTECTED]
Sent: 29 May 2004 13:32
To: 'Dave Carrera'; [EMAIL PROTECTED]
Subject: RE: [PHP] Preg_match question
I guess the simplest would be to use preg_match_all on
'//i'
Assuming that all your links are in that format, t
I guess the simplest would be to use preg_match_all on
'//i'
Assuming that all your links are in that format, this will extract all the
contents of the href portion of the links in your string. There was a regex
series on our magazine that also covered more complex examples of this kind.
Cheers
On Sat, 29 May 2004, Dave Carrera wrote:
>
> Link returned = Of to some page
>
> The bit I want to play with is ./somepage.php.
>
$str = 'Of to some page';
if( preg_match("//Ui", $str, $matches) )
echo $matches[1];
else
echo "string didn't match";
--
Jeroen
Always code as if t
Hi,
Saturday, February 22, 2003, 12:35:15 PM, you wrote:
AC> My apologies in advance if this too basic or there's a solution easily
AC> found out there, but after lots of searching, I'm still lost.
AC> I'm trying to build a regexp that would parse user-supplied text and
AC> identify cases wher
Hi,
Saturday, February 22, 2003, 12:35:15 PM, you wrote:
AC> My apologies in advance if this too basic or there's a solution easily
AC> found out there, but after lots of searching, I'm still lost.
AC> I'm trying to build a regexp that would parse user-supplied text and
AC> identify cases wher
d
to check the output of that to make sure there aren't any extraneous
tags.
Andy
> -Original Message-
> From: John W. Holmes [mailto:[EMAIL PROTECTED]
> Sent: Saturday, February 22, 2003 5:04 PM
> To: 'Andy Crain'; [EMAIL PROTECTED]
> Subject: RE: [PHP] preg_matc
copy
today. http://www.phparch.com/
> -Original Message-
> From: Andy Crain [mailto:[EMAIL PROTECTED]
> Sent: Saturday, February 22, 2003 4:54 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] preg_match question: locating unmatched HTML tags
>
> John,
> Thanks. I'm consi
n
checking its first match, at .
Andy
> -Original Message-
> From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED]
> Sent: Saturday, February 22, 2003 5:48 AM
> To: Andy Crain
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] preg_match question: locating unmatched HTML tags
>
TED]
> Sent: Saturday, February 22, 2003 1:06 AM
> To: 'Andy Crain'; [EMAIL PROTECTED]
> Subject: RE: [PHP] preg_match question: locating unmatched HTML tags
>
> > I'm trying to build a regexp that would parse user-supplied text and
> > identify cases where
At 03:35 22.02.2003, Andy Crain said:
[snip]
>My apologies in advance if this too basic or there's a solution easily
>found out there, but after lots of searching, I'm still lost.
>
>I'm trying to build a regexp that would parse user-supplied text and
>identi
> I'm trying to build a regexp that would parse user-supplied text and
> identify cases where HTML tags are left open or are not properly
> matched-e.g., tags without closing tags. This is for a sort
of
> message board type of application, and I'd like to allow users to use
> some HTML, but just
25 matches
Mail list logo