f



Help me with a regular expression for PHP

I have no idea where to get help on RE stuff.  Since it's for a PHP app
I thought I would ask here to see if there was some RE pros.  Basically
I'm doing some template stuff and I wanted to use a
preg_replace_callback function to call another function when the
criteria of the RE expression is matched but have no idea how to
accomplish it.

So I start with this:
/<(input|select|textarea)[^>]*name\s*\=\s*\"[_a-zA-Z0-9\s]*\"[^>]*>/

but need to modify it so it only matches if it has '{' characters in
the name but to not match if it does not.

So this would not match:
<input name="test">

But this would match:
<input name="test{0}">

Thanks much in advance.

0
cendrizzi (8)
10/29/2006 9:44:18 PM
comp.lang.php 32646 articles. 0 followers. Post Follow

13 Replies
753 Views

Similar Articles

[PageSpeed] 56

cendrizzi wrote:
> So I start with this:
> /<(input|select|textarea)[^>]*name\s*\=\s*\"[_a-zA-Z0-9\s]*\"[^>]*>/

You'd better not use regular expressions to validate HTML.
The following line is perfectly valid HTML (I think in any version)

    <input type="text" name="x><y" id="xy">

> but need to modify it so it only matches if it has '{' characters in
> the name but to not match if it does not.
>
> So this would not match:
> <input name="test">
>
> But this would match:
> <input name="test{0}">

Get the name. Verify it has '{' and '}' (in that order and once only?)

    <?php
    $name = get_name('<input name="test{0}">'); // 'test{0}'
    if (name_is_valid($name)) {
      // whatever
    }
    
    function get_name($html) {
      return 'test{0}'; // sorry!
    }

    function name_is_valid($name) {
      if (($p1 = strpos($name, '{')) === false) return false;
      if (strpos($name, '{', $p1+1) !== false) return false;
      if (($p2 = strpos($name, '}')) === false) return false;
      if (strpos($name, '}', $p2+1) !== false) return false;
      return $p1 < $p2;
    }
    ?>

-- 
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
0
hexkid (576)
10/29/2006 11:17:02 PM
It's not for validation.  It's for some custom template stuff that
tells my stuff where to store the value of the form element in the
session.  That may not make sense but it's what I need for my
application.  So I use the ob_start, etc functions and use regular
expressions against the buffer to manipulate the html or change the
behaivor of certain elements.  I could just get the name of each
element and check them using strpos or strstr for the '{' character but
I hoped I could use RE to check from the start if it had that so it
wouldn't require the extra string searches.

Hope that makes sense, it's always a bit of a challenge to explain
things clearly, especially if the program is quite a big one.

On Oct 29, 4:17 pm, Pedro Graca <hex...@dodgeit.com> wrote:
> cendrizzi wrote:
> > So I start with this:
> > /<(input|select|textarea)[^>]*name\s*\=\s*\"[_a-zA-Z0-9\s]*\"[^>]*>/You'd better not use regular expressions to validate HTML.
> The following line is perfectly valid HTML (I think in any version)
>
>     <input type="text" name="x><y" id="xy">
>
> > but need to modify it so it only matches if it has '{' characters in
> > the name but to not match if it does not.
>
> > So this would not match:
> > <input name="test">
>
> > But this would match:
> > <input name="test{0}">Get the name. Verify it has '{' and '}' (in that order and once only?)
>
>     <?php
>     $name = get_name('<input name="test{0}">'); // 'test{0}'
>     if (name_is_valid($name)) {
>       // whatever
>     }
>
>     function get_name($html) {
>       return 'test{0}'; // sorry!
>     }
>
>     function name_is_valid($name) {
>       if (($p1 = strpos($name, '{')) === false) return false;
>       if (strpos($name, '{', $p1+1) !== false) return false;
>       if (($p2 = strpos($name, '}')) === false) return false;
>       if (strpos($name, '}', $p2+1) !== false) return false;
>       return $p1 < $p2;
>     }
>     ?>
>
> --
> I (almost) never check the dodgeit address.
> If you *really* need to mail me, use the address in the Reply-To
> header with a message in *plain* *text* *without* *attachments*.

0
cendrizzi (8)
10/30/2006 12:42:51 AM
cendrizzi top-posted and totally messed it up:
> I hoped I could use RE to check from the start if it had that so it
> wouldn't require the extra string searches.


    <?php
    $data = array(
      '<input type="text" name="no!" id="test0">          ',
      '<input type="text" name="no{!}" id="test0">        ',
      '<input type="text" name="test0" id="test0">        ',
      '<input type="text" name="test 0" id="test0">       ',
      '<input type="text" name="test{0}" id="test0">      ',
      '<input type="text" name="test {0}" id="test0">     ',
      '<input type="text" name="test{0}test" id="test0">  ',
      '<input type="text" name="test {0} test" id="test0">',
    );
    $rx = '/<(input|select|textarea)[^>]*' .
        # 'name\s*\=\s*\"[_a-zA-Z0-9\s]*\"' . // your original version
          'name\s*\=\s*\"[_a-zA-Z0-9\s]*{[_a-zA-Z0-9\s]*}[_a-zA-Z0-9\s]*\"' .
        #                            ---^---         ---^---
          '[^>]*>/';
    ### I think there's a few \ too many in there,
    ### I didn't look at it very attentively
    
    foreach ($data as $val) {
      echo $val, ' :: ';
      if (preg_match($rx, $val)) {
        echo 'M';
      } else {
        echo 'No m';
      }
      echo "atch.\n";
    }
    ?>

-- 
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
0
hexkid (576)
10/30/2006 2:17:03 AM
Pedro Graca wrote:
> The following line is perfectly valid HTML (I think in any version)
>
>     <input type="text" name="x><y" id="xy">

I would have to disagree
<input type="text" name="x>    is invalid:  no closing quote around
name value
<y" id="xy">   is invalid.   y" isn't a valid cname  (only
alphanumeric?)

if you want 'x><y' as a value you'd need to use name="x&gt;&lt;y"

0
10/30/2006 4:18:44 AM
I had a similar RE problem and never figured it out, or found an
answer.  I basically ended up using two callbacks..or doing the 2nd
check (does it contain "x") in the first callback

Capture and send all name values to the first (whether or not they
contain the {)
check whether or not the name value contains "{" inside that

cendrizzi wrote:
> I have no idea where to get help on RE stuff.  Since it's for a PHP app
> I thought I would ask here to see if there was some RE pros.  Basically
> I'm doing some template stuff and I wanted to use a
> preg_replace_callback function to call another function when the
> criteria of the RE expression is matched but have no idea how to
> accomplish it.
>
> So I start with this:
> /<(input|select|textarea)[^>]*name\s*\=\s*\"[_a-zA-Z0-9\s]*\"[^>]*>/
>
> but need to modify it so it only matches if it has '{' characters in
> the name but to not match if it does not.
>
> So this would not match:
> <input name="test">
>
> But this would match:
> <input name="test{0}">
> 
> Thanks much in advance.

0
10/30/2006 4:28:04 AM
cendrizzi wrote:
> I have no idea where to get help on RE stuff.  Since it's for a PHP app
> I thought I would ask here to see if there was some RE pros.  Basically
> I'm doing some template stuff and I wanted to use a
> preg_replace_callback function to call another function when the
> criteria of the RE expression is matched but have no idea how to
> accomplish it.
>
> So I start with this:
> /<(input|select|textarea)[^>]*name\s*\=\s*\"[_a-zA-Z0-9\s]*\"[^>]*>/
>
> but need to modify it so it only matches if it has '{' characters in
> the name but to not match if it does not.
>
> So this would not match:
> <input name="test">
>
> But this would match:
> <input name="test{0}">
>
> Thanks much in advance.

Well, just change the [_a-zA-Z0-9\s]* part to [\w\s]*{[\w\s]*}. Of
course, you'll need to do proper capturing in order to form the
replacement string.

\w is equivalent to [_a-zA-Z0-9] by the way.

0
chernyshevsky (2297)
10/30/2006 5:04:58 AM
No I didn't know that \w was the same.  What do you mean by proper
capturing.  I really am a 2 year old when it comes to RE stuff.

Thanks!

On Oct 29, 10:04 pm, "Chung Leong" <chernyshev...@hotmail.com> wrote:
> cendrizzi wrote:
> > I have no idea where to get help on RE stuff.  Since it's for a PHP app
> > I thought I would ask here to see if there was some RE pros.  Basically
> > I'm doing some template stuff and I wanted to use a
> > preg_replace_callback function to call another function when the
> > criteria of the RE expression is matched but have no idea how to
> > accomplish it.
>
> > So I start with this:
> > /<(input|select|textarea)[^>]*name\s*\=\s*\"[_a-zA-Z0-9\s]*\"[^>]*>/
>
> > but need to modify it so it only matches if it has '{' characters in
> > the name but to not match if it does not.
>
> > So this would not match:
> > <input name="test">
>
> > But this would match:
> > <input name="test{0}">
>
> > Thanks much in advance.Well, just change the [_a-zA-Z0-9\s]* part to [\w\s]*{[\w\s]*}. Of
> course, you'll need to do proper capturing in order to form the
> replacement string.
> 
> \w is equivalent to [_a-zA-Z0-9] by the way.

0
cendrizzi (8)
10/30/2006 5:18:59 AM
BKDotCom:

> Pedro Graca wrote:
>
> > The following line is perfectly valid HTML (I think in any version)
> >
> >     <input type="text" name="x><y" id="xy">

Yes, yes it is.  In any version.

> I would have to disagree

Run it through a validator.  You'll find it's valid.

The 'name' attribute is defined as CDATA, so pretty much anything goes
if the attribute value is quoted, including literal less-than and
greater-than signs.

> <input type="text" name="x>    is invalid:  no closing quote around
> name value

Yes, as a start-tag _in itself_.  That wasn't Pedro's example though;
his example was the whole

| <input type="text" name="x><y" id="xy">

> <y" id="xy">   is invalid.   y" isn't a valid cname

As a tag in itself, it is invalid HTML, yes.  It isn't invalid as part
of the example above.

> (only alphanumeric?)

Generic identifiers (aka, element type names) must begin with upper- or
lowercase letters.

> if you want 'x><y' as a value you'd need to use name="x&gt;&lt;y"

No.  You only need to replace '<' and '>' with references where they
would be understood as something other than character data.

-- 
Jock

0
2004 (518)
10/30/2006 9:21:33 AM
Chung Leong wrote:
> \w is equivalent to [_a-zA-Z0-9] by the way.

It is /almost/ equivalent:

    ~$ php -r 'echo (preg_match("/^\w+$/", "Gra�a"))?("yes"):("no"), "\n";'
    yes
    ~$ php -r 'echo (preg_match("/^[_a-zA-Z0-9]+$/", "Gra�a"))?("yes"):("no"), "\n";'
    no

-- 
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
0
hexkid (576)
10/30/2006 11:17:03 AM
BKDotCom wrote:
> Pedro Graca wrote:
> 
>>The following line is perfectly valid HTML (I think in any version)
>>
>>    <input type="text" name="x><y" id="xy">
> 
> 
> I would have to disagree
> <input type="text" name="x>    is invalid:  no closing quote around
> name value
> <y" id="xy">   is invalid.   y" isn't a valid cname  (only
> alphanumeric?)
> 
> if you want 'x><y' as a value you'd need to use name="x&gt;&lt;y"
> 

Actually, it is legal.  name="x><y" is a perfectly valid tag and value. 
  &lt; and &gt; aren't required here because they are within a quoted 
string in a tag.

You do need &lt; and &gt; in plain text, however, when they may be 
mistaken for the start/end of a tag.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
0
jstucklex (14659)
10/30/2006 12:13:31 PM
cendrizzi wrote:
> No I didn't know that \w was the same.  What do you mean by proper
> capturing.  I really am a 2 year old when it comes to RE stuff.
>
> Thanks!
>
> On Oct 29, 10:04 pm, "Chung Leong" <chernyshev...@hotmail.com> wrote:
> > cendrizzi wrote:
> > > I have no idea where to get help on RE stuff.  Since it's for a PHP app
> > > I thought I would ask here to see if there was some RE pros.  Basically
> > > I'm doing some template stuff and I wanted to use a
> > > preg_replace_callback function to call another function when the
> > > criteria of the RE expression is matched but have no idea how to
> > > accomplish it.
> >
> > > So I start with this:
> > > /<(input|select|textarea)[^>]*name\s*\=\s*\"[_a-zA-Z0-9\s]*\"[^>]*>/
> >
> > > but need to modify it so it only matches if it has '{' characters in
> > > the name but to not match if it does not.
> >
> > > So this would not match:
> > > <input name="test">
> >
> > > But this would match:
> > > <input name="test{0}">
> >
> > > Thanks much in advance.Well, just change the [_a-zA-Z0-9\s]* part to [\w\s]*{[\w\s]*}. Of
> > course, you'll need to do proper capturing in order to form the
> > replacement string.
> >
> > \w is equivalent to [_a-zA-Z0-9] by the way.

By that I mean you need to grab the substrings which precedes and
follows the text inside the quotation marks. If the input is

<input name="test{0}" size="40">

you'd want

<input name="

and

" size="40">

so that you can form the replacement <input name=" + DATA + "
size="40">.

Presumably you'd want 'test' and '0' as well for looking up the data.

0
chernyshevsky (2297)
10/30/2006 2:04:51 PM
John Dunlop wrote:
> Run it through a validator.  You'll find it's valid.

Will I?

http://validator.w3.org/check
Warning  character "<" is the first character of a delimiter but
occurred as data
This message may appear in several cases:
    * You tried to include the "<" character in your page: you should
escape it as "&lt;"
    * You used an unescaped ampersand "&": this may be valid in some
contexts, but it is recommended to use "&amp;", which is always safe.
    * Another possibility is that you forgot to close quotes in a
previous tag.

0
10/30/2006 5:02:18 PM
On 30 Oct 2006 09:02:18 -0800, "BKDotCom" <bkfake-google@yahoo.com> wrote:

>John Dunlop wrote:
>> Run it through a validator.  You'll find it's valid.
>
>Will I?

 You certainly should. I've just tried it against the W3C validator, and it
agreed it's valid.

>http://validator.w3.org/check
>Warning  character "<" is the first character of a delimiter but
>occurred as data
>This message may appear in several cases:
>    * You tried to include the "<" character in your page: you should
>escape it as "&lt;"
>    * You used an unescaped ampersand "&": this may be valid in some
>contexts, but it is recommended to use "&amp;", which is always safe.
>    * Another possibility is that you forgot to close quotes in a
>previous tag.

Result:  	 Passed validation
File:	test.html
Encoding:	iso-8859-1
Doctype:	HTML 4.01 Transitional
This Page Is Valid HTML 4.01 Transitional!

 Here's what I uploaded:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <title>test</title>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form method="post" action="test.php">
 <input type="text" name="x><y" id="xy">
</form>
</body>
</html>

 (the <meta> being there because I validated it by upload rather than from a
real site that would have sent the relevant HTTP header instead)

 What did you upload?

-- 
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
0
andy171 (2271)
10/30/2006 5:10:44 PM
Reply:

Similar Artilces:

PHP regular expressions
Hello, I am writing an elearning software with php. I need a script to recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on. Could anyone tell me how can I do this using regular expressions? Regards, Albert Achtenberg Albert <albert@arbel-designs.com> wrote: > I am writing an elearning software with php. I need a script to > recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on. > Could anyone tell me how can I do this using regular expressions? So basically you need a regexp tutorial. I don't know any but studing http://nl.php.net/manual...

HELP!! PHP Warning: PHP Startup: Unable to load dynamic library 'c:\PHP\Ext\php_mysql.dll'
Why do I keep getting this error mesgage on my phpinfo() page trying to get PHP and MySQL to communicate? I am running this in IIS. Here's what I have - My php.ini resides in my C:\WINNT directory. In it, I have removed the ';' from the extension=php_mysql.dll. Also in the php.ini file I set extension_dir = c:\PHP\Ext In c:\PHP\Ext I have the following files: libmysqli.dll libmySQL.dll php5apache2.dll (Do I need this since I am using IIS)? php5ts.dll php_mysql.dll Any help would be tremendously appreciated. I have spent a ton of time on this. Thanks. MS wrote: > Wh...

PHP Training Institute In Delhi, Live Projects on PHP. Short Term PHP Courses, PHP Scripts, PHP Training with Live Projects.
Vserve Global offers short term PHP: Hypertext Preprocessor Training Course, which is a widely used, general-purpose scripting language that was originally designed for web development, to produce dynamic web pages. It can be embedded into HTML and generally runs on a web server, which needs to be configured to process PHP code and create web page content from it. It can be deployed on most web servers and on almost every operating system and platform free of charge.PHP is installed on over 20 million websites and 1 million web servers. TOPICS:- >> Core PHP Language >> HTML, Cascad...

PHP within PHP...
I took over the support of a website that is set up something like this inside one of the pages: include_once("header.php"); <?php //to get the content of the page they do this: $content = mysql_query("select content etc...); echo $content; ?> include_once("footer.php"); I am having problems evaluating any php that is used in the mysql content. Is there a way to get the mysql withing the mysql to run? Thank you for your time, Mandragon On Sep 17, 12:56 pm, Mandrago...@gmail.com wrote: > I took over the support of a website that is set up something like > this inside one of the pages: > > include_once("header.php"); > > <?php > //to get the content of the page they do this: > $content = mysql_query("select content etc...); > > echo $content; > ?> > > include_once("footer.php"); > > I am having problems evaluating any php that is used in the mysql > content. Is there a way to get the mysql withing the mysql to run? > > Thank you for your time, > > Mandragon Sorry, The question should read: "Is there a way to get the php withing the echo $htmlcontent to run?" Of course you are, $content is a resource. The MySQL Query resource. try this: $content = mysql_query('bla bla bla'); while ($row = mysql_fetch_assoc($content)) { $result[] = $row; } $content = $result; Now you can use $content ;). In answer to your edit... eval($co...

Question on PHP regular expressions
In PHP I have many more options for functions that do regular expression than I did in Perl. My question is what is the best one to use for doing the following: Give the following: {Somestring.somestring.somestring} blah blah {somestring} value here not used {more.text.here} I want an array like the following: [0] => Somestring.somestring.somestring [1] => somestring [2] => more.text.here So basically I just want to capture the contents (alpha-numeric + periods) inside of curly braces. Thanks for any help. sberry <sean@buildingonline.com> writes: > In PHP I have many more options for functions that do regular > expression than I did in Perl. My question is what is the best one to > use for doing the following: > > Give the following: > {Somestring.somestring.somestring} blah blah {somestring} value here > not used {more.text.here} > > I want an array like the following: > [0] => Somestring.somestring.somestring > [1] => somestring > [2] => more.text.here > > So basically I just want to capture the contents (alpha-numeric + > periods) inside of curly braces. > > Thanks for any help. This should get you started: $string = "{Somestring.somestring.somestring} blah blah {somestring} value here not used {more.text.here}"; $pattern = '/\{.+?\}/'; preg_match_all($pattern, $string, $matches); print_r($matches); Hope that helps, On Nov 8, 11:17 am, Carl <c.gro...@gmail.com>...

PHP and regular expressions #2
Hi, I'm new to this group and regular expressions. I want to extract text from a newspaper website using regular expressions and php I'm using this regular expression at the moment $regexp = "%<table cellspacing=\"0\" cellpadding=\"0\"> (.+) <img height=\"1\" alt=\"Today's News\" />%s"; Each news story is in between those tags , So if I extract those chunks of html using preg_match($regexp,$document,$matches); where $document is a handle on the file. I can store them in %matches for further processing. Alas it does not work and i cannot figure out why Can anyone help? Thanks __where $document is a handle on the file__ the 2nd parameter should be a string read the file to a string... Do you really want the space around "(.+)" ? you can clean this up by enclosing it in '' rather than "" $regexp = '%<table cellspacing="0" cellpadding="0"> (.+) <img height="1" alt="Today's News" />%s'; On Feb 28, 12:03 pm, "Damo" <cormacdeba...@gmail.com> wrote: > Hi, > I'm new to this group and regular expressions. I want to extract text > from a newspaper website using regular expressions and php > I'm using this regular expression at the moment > > $regexp = "%<table cellspacing=\"0\" cellpadding=\"0\"> (.+) <img > height=\"1\" alt=...

php to php obj
Hi All, Is there any tool to convert the .php files into its object files in deploying the files to other's server like java classes are deployed? Thanks in advance --AR John7481 <arjohn7481@hotmail.com> wrote or quoted: > Is there any tool to convert the .php files into its object files in > deploying the files to other's server like java classes are deployed? To what end? Do you want a PHP obfuscator? They tend not to be needed - since the code remains on the server. Do you want a PHP squeezer? Again - since PHP remains on the server that is of reduced importance. PHP obfuscators and squeezers are out there - but what exactly are you looking for? -- __________ |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply. With total disregard for any kind of safety measures Tim Tyler <tim@tt1lock.org> leapt forth and uttered: > John7481 <arjohn7481@hotmail.com> wrote or quoted: > >> Is there any tool to convert the .php files into its object >> files in deploying the files to other's server like java >> classes are deployed? > > To what end? > > Do you want a PHP obfuscator? They tend not to be needed - > since the code remains on the server. > > Do you want a PHP squeezer? Again - since PHP remains on the > server that is of reduced importance. > > PHP obfuscators and squeezers are out there - but what exactly > are you looking for? I think he'...

Need PHP expression help
Hi, I need to validate a string of text against an expression and having difficulty putting it together. Basically, I want to count the number of words in a string that are separated by commas. If the count is more than a predetermined number 9, it will do something, else something else. Thank you for assistance. Ragnorack67@hotmail.com wrote: > Hi, I need to validate a string of text against an expression and > having difficulty putting it together. Basically, I want to count the > number of words in a string that are separated by commas. If the count > is more than a predeter...

php outside php (?)
Sounds weird, i know. What i want/wonder is the following: PHP can do the next: <?php if($foo == 'bar') { ?> Ow yeah, foo is bar! <?php }; ?> But how can i do the following: <?php $foo= ?> this is what foo looks like. <?php }; ?> This way i could edit the content of $foo in DW's design-view. I hope it's clear enough for you all to understand... Greetings frizzle. frizzle wrote: > But how can i do the following: > > <?php > > $foo= > > ?> > this is what foo looks like. > <?php > > }; > > ?> > > This way i could edit the content of $foo in DW's design-view. > I hope it's clear enough for you all to understand... <?php ob_start(); ?> this is what foo looks like. <?php $foo=ob_get_clean(); ?> -- Justin Koivisto - justin@koivi.com http://koivi.com Wow, little late on the reply, but i still wanted to thank you for your help. This is exactly what i meant, and it works great! :D Thanks again. ...

Regular expression example on PHP.net
Howdy folks, On this page at php.net http://www.php.net/features.http-auth there's a regular expression in Example 34.2. It's supposed to parse out the different values being passed in the header. I know what it's supposed to do, so I have a vague idea of what's being done in the RE, but I've been having a heck of a time figuring out what each part of the RE is actually doing. Here's what I have so far: preg_match_all('@(\w+)=(?:([\'"])([^\2]+)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); //'@ //(\w+) Any word character (letter/digit/_), 1 or more //= Equal sign //(?: This submatch will not be captured (still available for later matching) //([\'"]) A single or double quote //([^\2]+) Not start of text (STX)?, 1 or more //\2| //([^\s,]+) Not whitespace or comma, 1 or more //) //@' I'm unclear as to what the second \2 does, as well as which parts the OR applies to. And what are the @s for? Thanks for any help, ZF -- Posted via a free Usenet account from http://www.teranews.com On Fri, 07 Sep 2007 08:02:07 +0200, Zenofobe <fake_email@fake_domain.com= > = wrote: > Howdy folks, > > On this page at php.net > http://www.php.net/features.http-auth > there's a regular expression in Example 34.2. It's supposed to parse = out > the different values being passed in the header. I know what it's > supposed to do, so I have a vague i...

Converting PERL regular expression to PHP?
Hi, I'm in the process of converting some PERL to PHP. Thus, is it possible to leave the following line as is: if ($id =~ /vvvvv/g) { ... } If not, can someone provide PHP equivalent? BTW, I have checked the syntax using 'php -l' because I'm not an expert of PERL but I'm using various references to do the conversion. However, I was able to locate this particular construct. Thanks in advance, -Conrad Hi, the last couple of sentences should read: If not, can someone provide PHP equivalent? BTW, I have checked the syntax using 'php -l'. Also, I'...

Needs help with old PHP scrips on new server with update version of PHP
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old scripts working on a new server with the most recent version of PHP. I've pretty much taken care of all the various errors that were popping up. Most only pointed out out non-fatal undefined or assumed variables. I've been able to cure most of them by adding single quotes to array variables and pre-defining variables that weren't being defined previously. But I'm absolutely ...

Regular Expression for replacing images through URLs in PHP
Hi! I want to replace images through URLs with the help of a regular expression. For example: <img src='http://xxxxx.net/photo/small.jpg'> should be replaced through: <a href='http://xxxxx.net/photo/small.jpg'>Link</a> Another problem are emoticons, which are also included as <img>. Therefore I would like to extend the upper regular expression that the image should only be replaced through an URL, if the src attribute of the img tag does not start with "/modules/emoticons/". Thanks in advance, Markus On Tue, 19 Jul 2005 10:31:30 +02...

Best PHP Training | PHP Development Training | PHP Training Institute
Tops Technologies provides php and mysql certification courses in ahmedabad, baroda, surat, Rajkot, Udaipur, Gujarat, india.PHP Training with MySQL is an introductory course in the PHP and MySQL technology. Mysql and php training course, php for beginners, sql training courses, PHP Training courses, php courses, mysql training courses, php mysql course. For More Details :- http://www.tops-int.com ...

php regular expression doesn't match
Hi PHP's regular expression look like doesn't support .*? syntax. So i cannot match the shortest match. For exmaple: $str="a1b a3b"; $str1=ereg_replace("a.*b", "peter", $str1); will produce "peter", but i want "peter peter", so how to? thanks from Peter (cmk128@hotmail.com) cmk128@hotmail.com wrote: > Hi Hi, > PHP's regular expression look like doesn't support .*? syntax. So i > cannot match the shortest match. For exmaple: > > $str="a1b a3b"; Typo. That was $str1="a1b a3b" I expect. > $str1=ereg_replace("a.*b", "peter", $str1); > will produce "peter", but i want "peter peter", so how to? > Yes, * is greedy. I do not know your real-world example, but maybe using a wordboundary can solve your problem? eg: $str1=ereg_replace("/a.*b\b/", "peter", $str1); > thanks > from Peter (cmk128@hotmail.com) > Regards, Erwin Moller Erwin Moller wrote: > cmk128@hotmail.com wrote: >> Hi > > Hi, > >> PHP's regular expression look like doesn't support .*? syntax. So i >> cannot match the shortest match. For exmaple: >> >> $str="a1b a3b"; > > Typo. That was $str1="a1b a3b" I expect. > >> $str1=ereg_replace("a.*b", "peter", $str1); >> will produce "peter", but i want "p...

Does PHP need the .php extension ?
Hi guys, When I use PHP I give my file the .php extension. I always wondered if it could be an .htm page with a <script> block that the PHP resides in, the same way you would do JavaScript. If you can do it that way are there any benifits to that method ? Take care, Cyrus "Cyrus D." <satan@invalid.org> writes: > Hi guys, > > When I use PHP I give my file the .php extension. I always wondered if it > could be an .htm page with a <script> block that the PHP resides in, the > same way you would do JavaScript. If you can do it that way are the...

php notification through php sdk
Hi there I want to build a e-commerce website similar to wish.com and I have chosen opencast as my framework of choice. Now wish has a feature that when you save a product in wish and if you are logged in with Facebook or gmail all of your friends will get a notification that your friends has saved a item on wish. I want a similar feature on my site Now I know Facebook provide a sdk JavaScript and php and wish might be using something similar but I am using open cart can I open home page or product page in the sdk Thanks On 3/20/2015 7:30 AM, apoorv.kanungo@gmail.com wrote: &g...

PHP does not parse .PHP files
I have this problem with PHP that someone might be able to help. With CLI, I am able to execute my .php files. For example, if I type "php phpinfo.php" , this works fine on my system. If I put the phpinfo.php file is in /var/www/html and I try to access it through the browser, I get the content of the file and not the execution of the file. Instead of display the info of PHP, I got the text of the file as: <?php phpinfo(); ?> Why? Thanks Phong Ho wrote: >I have this problem with PHP that someone might be able to help. > >With CLI, I am able to execute my ....

php://memory and php://temp
http://php.net/manual/en/wrappers.php.php per the documentation: php://memory and php://temp are both listed under "Allows Appending" what am I missing / what's the point? They only seem to work with read/write modes such as fopen('php://memory','rw'); closing the handle, or trying to open another handle without closing the first essentially erase the contents... so what's the point of fopen('php://memory','a') ? you'll a) be appending nothing, b) no way to read what you just wrote? sure would be nice if you could $fh = fopen('php://memory', 'w'); fwrite($fh, 'test string'); fclose($fh); $fh = fopen('php://memory', 'r'); $result = fgets($fh,2048); fclose($fh); echo $result; On 10/12/2010 9:44 PM, BKDotCom wrote: > http://php.net/manual/en/wrappers.php.php > per the documentation: php://memory and php://temp are both listed > under "Allows Appending" > > what am I missing / what's the point? > > They only seem to work with read/write modes such as > fopen('php://memory','rw'); > > closing the handle, or trying to open another handle without closing > the first essentially erase the contents... so what's the point of > fopen('php://memory','a') ? > you'll > a) be appending nothing, > b) no way to read what you just wrote? > > sure would be nice if you could > > $fh = ...

Send array from php to php
HI every one I' try to send array from web page to php file but no data are show I'm using session to store data and this is my code //////////////////////////////////////////////////////////////////////// $data = $cart_items; session_register('data'); foreach ($cart_items as $cart_item) { echo "<tr>"; echo " <td><span class='style2'>".$cart_item->name."</span></td>"; echo " <td><span class='style2'>".$cart_item->description."</ span></td>"; echo " <td><span class='style2'>".$cart_item->price." S.R.</span></ td>"; echo " <td><span class='style2'>".$cart_item->quantity."</span></ td>"; echo " <td><span class='style2'>".$cart_item->price * $cart_item- >quantity."</span></td>"; echo " <td><span class='style4'><a href='order.php?action=del&id=". $cart_item->object_id."'>[del]</a></span></td>"; echo "</tr>"; \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ and this is my php code to get the data //////////////////////////////////////////////////////// <?php foreach ($data as $item) { echo "<tr>"; print " &l...

about php lang
plz told me that what is the php lang., how does it works and where it used. mani <msb.jod@gmail.com> wrote: > plz told me that what is the php lang., how does it works and where it > used. There is a good explanation at http://lmgtfy.com/?q=php regards Henrik -- The address in the header is only to prevent spam. My real address is: hc3(at)poolhem.se Examples of addresses which go to spammers: root@localhost postmaster@localhost On 16 Jun 2009, mani <msb.jod@gmail.com> wrote: > plz told me that what is the php lang., how does it works and > where it used. Lulz. <http://www.google.com/> -- ~Curtis Anonymous (1984 IOCCC winner): int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\ o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);} mani schreef: > plz told me that what is the php lang., how does it works and where it > used. http://en.wikipedia.org/wiki/Php Tip: If you want to learn something about a subject totally new to you, try wikipedia for a reasonable intro. Regards, Erwin Moller -- "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." -- C.A.R. Hoare ...

Php constants in php.ini
I am trying to set user_agent = PHP_VERSION in php.ini. In my php.ini the instructions say that you can use constants in the php.ini file. The only constants I can get to work, though, are the error level constants like E_ALL, E_ERROR, E_WARNING, etc., ... Is anyone aware of some sort of trick to getting others to work? (I was thinking it would be nice to have the user agent string used by my Php scripts to use PHP_VERSION in the string.) -- ***************************** Chuck Anderson • Boulder, CO http://www.CycleTourist.com Integrity is obvious. The lack of it is common. *****...

PHP with Indian PHP Developers
Dear all, If you want to make a PHP web application, or need to <a href="http:// www.virtueinfo.com/php-developers/hire-php-programmers-developers-india.htm">Hire PHP Developer</a>contact a leading <a href="http://www.virtueinfo.com/ php-developers/php-web-development.htm"> PHP Web Development Compnay</ a> <a href="http://www.virtueinfo.com/php-developers/php-web-programming- php-developers-india.htm">Offshore PHP web development India</a> On Thu, 25 Feb 2010 01:37:02 -0800 (PST), Virtue Info wrote: > Dear all, > > > If you want to make a PHP web application, or need to <a href="http:// > www.example.com/php-developers/hire-php-programmers-developers-india.htm">Hire > PHP Developer</a>contact a leading <a href="http://www.example.com/ > php-developers/php-web-development.htm"> PHP Web Development Compnay</ > a> > > ><a href="http://www.example.com/php-developers/php-web-programming- > php-developers-india.htm">Offshore PHP web development India</a> > Third time's the charm? Not exactly a ringing endorsement of the skills you've got available or your testing method reliablity... -- 12. One of my advisors will be an average five-year-old child. Any flaws in my plan that he is able to spot will be corrected before implementation. --Peter Anspach's list of things to do as an ...

PHP Help
I have a script that pulls a .txt file and displays the results for me. I need the scipt to limit the number of letters to not more than 15 letters, but not 15 letters exactly. Can someone show me a code example on how to do this please? Thanks! On 9/28/2010 10:39 PM, John wrote: > I have a script that pulls a .txt file and displays the results for > me. > > I need the scipt to limit the number of letters to not more than 15 > letters, but not 15 letters exactly. > > Can someone show me a code example on how to do this please? > > Thanks! Wha...

Web resources about - Help me with a regular expression for PHP - comp.lang.php

Expression (sign language) - Wikipedia, the free encyclopedia
Signs with two different expressions. The pursed lips and partly closed eyes on the left, and raised lip on the right, are necessary for proper ...

Arab women artists and their long road to expression
At a London festival, female artists grapple with the issues facing their region and their own identities.

Christie’s Expressions At Trump Event Under Scrutiny
Donald Trump Holds Super Tuesday Election Night Press Conf. In Palm Beach PALM BEACH, FL - MARCH 01: Republican Presidential frontrunner Donald ...

Decoding The Facial Expressions Of The GOP Candidates
Trump's "crooked contemptuous" smile, Rubio's sheepish grin, and Cruz's upper lip of disgust dominated the debate. For tonight's Republican ...

You enjoy freedom of expression only because army guards borders: Delhi HC to Kanhaiya Kumar
The bail granted to Kanhaiya Kumar comes with several conditions, directives to JNU faculty and some serious observations

Bernie Sanders Brought His Finest Facial Expressions to the Democratic Debate
You may not like Bernie Sanders as a presidential candidate, but you’ve gotta admit, this man’s got some pretty expressive peepers. Read more... ...

Crosswords Help You Learn Regular Expressions
Regular expressions might seem arcane, but if you do any kind of software, they are a powerful hacker tool. Obviously, if you are writing software ...

Security, the Greatest Threat to Free Expression?
Like it or not, today we are all, in one way or another, engaged in a battle between perceived security and freedom of expression. And far too ...

Ruby Rose Helps Urban Decay Promote ‘Personal Self-Expression’ With New Modeling Campaign
Orange is the New Black actress Ruby Rose just signed a deal with cosmetics company, Urban Decay. The deal will certainly cast a positive light ...

It Turns Out Vanessa Hudgens' Expression of Love Was Highly Illegal
The Federal Government cares more about some old, dead, scratched up rocks in the desert than it cares about Vanessa Hudgens and Austin Butler ...

Resources last updated: 3/23/2016 9:42:35 PM