Re: [PHP] Regexp
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] ("David Balatero") wrote: > So, I guess i need a regexp to remove all the > \n and :space: chars. Here are some ideas: $out=preg_replace("/\s+/","",$in); //strip whitespace or $out=preg_replace("/\s+/"," ",$in); //replace whitespace with single space Note that you requested is different from your example, in which it looks like you are simply condensing multiple newlines down into a single newline. For that, something like this might be more appropriate: $out=preg_replace("/(\n|\r|\r\n)+/","\n",$in); Play around with 'em. -- CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] REGEXP
Why don't you explode(";",$header); ?? Ben -Original Message- From: Adrian D'Costa [mailto:[EMAIL PROTECTED]] Sent: Saturday, July 14, 2001 2:54 AM To: php general list Subject: [PHP] REGEXP Hi, I am trying to capture the Header from a mail for my webmail using php and pop3. The header is something like this: Content-Type: multipart/mixed; boundary="B42DA66C4EC07C9B572A58FC" When I use preg_split("/[\d;]*/", $buffer), I get Content-Type: multipart/mixed; What I want is to return the whole line split by the ";". I usually try to avoid regexp (too lazy) but now I want to use it. The final result I would need is: B42DA66C4EC07C9B572A58FC so that I can search in the body of the message for the rest of the parts. Any pointers would be helpful. Adrian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] REGEXP
Tried. It gives only MULTIPART/MIXED; since that is what is stored in the $buffer. I need the $buffer to read everything from: Content-Type: multipart/mixed; boundary="B42DA66C4EC07C9B572A58FC" even if there is a break or a new line. Adrian On Wed, 18 Jul 2001, Ben Bleything wrote: > Why don't you explode(";",$header); ?? > > Ben > > -Original Message- > From: Adrian D'Costa [mailto:[EMAIL PROTECTED]] > Sent: Saturday, July 14, 2001 2:54 AM > To: php general list > Subject: [PHP] REGEXP > > Hi, > > I am trying to capture the Header from a mail for my webmail using php > and > pop3. The header is something like this: > Content-Type: multipart/mixed; > boundary="B42DA66C4EC07C9B572A58FC" > > When I use preg_split("/[\d;]*/", $buffer), I get > Content-Type: multipart/mixed; > > What I want is to return the whole line split by the ";". I usually try > to avoid regexp (too lazy) but now I want to use it. The final result I > would need is: B42DA66C4EC07C9B572A58FC so that I can search > in the body of the message for the rest of the parts. > > Any pointers would be helpful. > > Adrian > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] REGEXP
I am not sure if I am understanding you... but if you just want to return the boundary try preg_match("|boundary=\"([^\"].+)\"|Uis", $text, $regs ); $boundary = $regs[1]; I am guessing that you want the boundary from the lines > to avoid regexp (too lazy) but now I want to use it. The final result I > would need is: B42DA66C4EC07C9B572A58FC so that I can search If you are looking for something else let me know Sheridan > -Original Message- > From: Adrian D'Costa [mailto:[EMAIL PROTECTED]] > Sent: Saturday, July 14, 2001 2:54 AM > To: php general list > Subject: [PHP] REGEXP > > Hi, > > I am trying to capture the Header from a mail for my webmail using php > and > pop3. The header is something like this: > Content-Type: multipart/mixed; > boundary="B42DA66C4EC07C9B572A58FC" > > When I use preg_split("/[\d;]*/", $buffer), I get > Content-Type: multipart/mixed; > > What I want is to return the whole line split by the ";". I usually try > to avoid regexp (too lazy) but now I want to use it. The final result I > would need is: B42DA66C4EC07C9B572A58FC so that I can search > in the body of the message for the rest of the parts. > > Any pointers would be helpful. > > Adrian > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] regexp magic
On Tue, 2002-05-28 at 16:56, Dan Harrington wrote: > Greetings everyone, > > I'm trying to do some regexp magic and just can't seem to > get it done with PHP. > > Basically I want to evaluate a word and if the last character > of the word is an 's', to knock it off, unless there are > two consecutives at the end of the word. > > So 'boys' would become 'boy' > and 'cars' would become 'car' > > However, I don't want > 'happiness' to become 'happines', so I need to stop > it where there are two consecutive 'ss' on the end of the word. > > $out=eregi_replace("[s]$",'',$in); will knock off the last one. > > I thought about: > > $out=eregi_replace("[^s][s]$",'',$in); > > but that won't work > > any ideas? > > thanks This does what you asked for, but that might not be what you really want...since the output from the following is: This is a block of spooges about happiness. Glasses won't work. Thi i a block of spooge about happiness. Glasse won't work. ...which doesn't make a hell of a lot of sense. :) Hope this helps anyway. -- Torben Wilson <[EMAIL PROTECTED]> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RegExp help..
On Mon, 12 Mar 2001 12:10, John Vanderbeck wrote: > I really wish I could figure these darn things out :) I have a task I > need to do, and i'm certain I could do this easily with a regexp.. > > I have a file name in the format MMDDYY-*.txt...I need to parse it to > determine if the month and year matches a specified month and year. > Day is irrelevant > > Can any of your regexp wizards help me? A non-regexp solution that comes to mind is to use substr() to extract the bits you want from the filename, assuming the filenames to be always as your example. So: $month = substr($filename,0,2); $year = substr($filename,4,2); Then you have the string values for month and year in the respective variables. -- David Robley| WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet| http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] RegExp help..
Try this: $ ereg("^([0-9]{2})[0-9]{2}([0-9]{2}).*", $var, $hits) if ($hits[1] == themonth && $hits[2] == theyear) { do_the_stuff } What it does is that it puts the first two digitst into $hits[1], skips the two nextcoming digits and finally puts the next two numbers into $hits[2] /Fredrik >> Ursprungligt meddelande << John Vanderbeck <[EMAIL PROTECTED]> skrev 2001-03-12, kl. 02:40:25 angående ämnet [PHP] RegExp help..: > I really wish I could figure these darn things out :) I have a task I need > to do, and i'm certain I could do this easily with a regexp.. > I have a file name in the format MMDDYY-*.txt...I need to parse it to > determine if the month and year matches a specified month and year. Day is > irrelevant > Can any of your regexp wizards help me? > Thanks! > - John Vanderbeck > - Admin, GameDesign > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] regexp for ' replacement
addslashes($textline) -Original Message- From: Thalis A. Kalfigopoulos [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 10:54 AM To: [EMAIL PROTECTED] Subject: [PHP] regexp for ' replacement Yet another regexpr question. If I have as part of a text: ...and then 'the quick brown fox jumped over the lazy dog's piano'... How can I substitute the single quote in "dog's" with say \' I want to aply a substitution for only the single quote that is between two single quotes and leave the rest of the text in between the same. Make sense for regexpr usage? TIA, thalis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] regexp for ' replacement
Nop. I don't want to affect the first and last ' of every line. On Fri, 5 Apr 2002, Rick Emery wrote: > addslashes($textline) > > -Original Message- > From: Thalis A. Kalfigopoulos [mailto:[EMAIL PROTECTED]] > Sent: Friday, April 05, 2002 10:54 AM > To: [EMAIL PROTECTED] > Subject: [PHP] regexp for ' replacement > > > Yet another regexpr question. > If I have as part of a text: > ...and then 'the quick brown fox jumped over the lazy dog's piano'... > > How can I substitute the single quote in "dog's" with say \' > I want to aply a substitution for only the single quote that is between two > single quotes and leave the rest of the text in between the same. > > Make sense for regexpr usage? > > TIA, > thalis > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] regexp for ' replacement
regexp is not what you need then You will require a character-by-character search/replace or try: which produces: $q= 'here's to you' $a= \'here\'s to you\' $z= 'here\'s to you' -Original Message- From: Thalis A. Kalfigopoulos [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 11:35 AM To: Rick Emery Cc: [EMAIL PROTECTED] Subject: RE: [PHP] regexp for ' replacement Nop. I don't want to affect the first and last ' of every line. On Fri, 5 Apr 2002, Rick Emery wrote: > addslashes($textline) > > -Original Message- > From: Thalis A. Kalfigopoulos [mailto:[EMAIL PROTECTED]] > Sent: Friday, April 05, 2002 10:54 AM > To: [EMAIL PROTECTED] > Subject: [PHP] regexp for ' replacement > > > Yet another regexpr question. > If I have as part of a text: > ...and then 'the quick brown fox jumped over the lazy dog's piano'... > > How can I substitute the single quote in "dog's" with say \' > I want to aply a substitution for only the single quote that is between two > single quotes and leave the rest of the text in between the same. > > Make sense for regexpr usage? > > TIA, > thalis > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP regexp powerful?
Are they powerful? Well they are compatible with PERL's Regular expressions...you should use the 'preg_' functions... Check the manual anyway...: http://www.php.net/manual/en/ref.pcre.php "Jeff Lewis" <[EMAIL PROTECTED]> wrote in message 009201c13704$b20abe90$76a1a8c0@LEWISJCIT">news:009201c13704$b20abe90$76a1a8c0@LEWISJCIT... I have a lot of scripts written in perl here and have been using PHP a lot now. I am wondering if PHPs regexps are powerful or not. I will show a small section of this code below that I clean up witht he perl scripts. It cleans it almost right up but take a look :) And YES there is actually information we use in this file :) Jeff ***BATCHJobBATCH_384,SubmittedbyPRDM ANOPERonNodeKWRB***%SET-W-NOTSET,err ormodifyingKWRB$DKA0:-CLI-E-IVDEVTYPE,invaliddevicetype-specifyamailboxdevic e$log*o=="logoff/full"needtohavecapabilities$tologout$iff$mode().eqs."INTERA CTIVE"thenprdmenu$logout/full$hellosystemKWRtakes0Hellosystem,haveaniceday$ setverify$znewdate$6sep01$heading$@clasNumb:1000@sort:BABYBEDDI@firs:6sep01L 9BC11758KWRN2N1V4$Diag1135247V2*cbe,99 *pe*tfNEWSGO*BF*ps6*ss6.5< ss130>*la104%*cpe*cse*ih6.*boBABY,BEDDING*bb*cpd*tfNEWSGO*ps6.*ss6.5*la104%* feforcrib.In- cludesmatchingCribMo-bile.$20.578-6231.*dih*p e*lcd*add*ic*IR .6*rs.5*la3.*rab< bc>*ru*fe $@clasNumb:1000@sort:BABYBEDDI@firs:6sep01L9BA46614KWRN2N3C7$Diag1117244V2*cbe,99*pe*tfNEWSGO*BF*ps6< bc>*ss6.5*la104%*cpe*cse*ih6.*bo*comMemo:sameplaced...e-maildee< 10>BABYBEDDING.*bb< bc>*cpd*tfNEWSGO*ps6.* ss6.5*la104%*feNoah'sArk fromSears,A1condition.$50firm.743-9923.*d ih*pe*lcd*add*i c*IR.6*rs.5*la3.*rab*ru*fe $@clasNumb:1000@sort:BABYBREAS@firs:6sep01L9BB31124KWRN1B1B5$Diag1131124V1*cbe,99*pe*tfNEWSGO*BF*ps6< bc>*ss6.5*la104%*cpe*cse*ih6.*bo*comMemo:samefaxed.dee<10>BABYBREAST*bb< bc>*cpd*tfNEWSGO*ps6.* ss6.5*la104%*fepump.Gerber.Likenew.$35.Call653-3355.*dih*pe*lcd*add*ic*IR.6*rs.5 *la3.*rab*ru* fe -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] regexp on user supplied link
reg.ex. something like (not tested): "]*>" this would give you the entire anchor tag, then go from there? or what about using the XML parsing routines, get it to find the anchors and give you it's attributes, then go from there? Martin -Original Message- From: Justin French [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 20, 2002 10:46 AM To: php Subject: [PHP] regexp on user supplied link Hi, I have a website which is based purely on user-added content. The problem with this is that some areas allow users to use links in the text, and it's difficult to ensure that they all have a decent knowledge of attributes such as tartget="_new", etc etc. So, I'd like a script that... 1. looks at $text for any link tags, and for each tag, does the following: 2. throws out everything except the HREF eg: http://www.somesite.com"; target="_new">click becomes http://www.somesite.com becomes javascript:something(); 3. prefixe the url with http://www.mysite.com OR http://mysite.com"; is an external link. 5. if it's an external link, suffix the URL with " TARGET="_new">, or if it's internal, suffix it with "> Anyway, that'd be a great start. From there, I might like to prex each external link to go thru a program called out.php to log affiliate activity, and I might like to retain onmouseover, onclick, onmouseout etc etc properties in the tag, I might like to ensure a session ID is found within each internal link, and stripped from each external link, ensure that the has a matching etc etc, but the above would be a great start. Any help, especially with steps 1, 2 & 4, would be much appreciated. Thanks in advance, Justin French http://indent.com.au http://soundpimps.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] regexp on user supplied link
I absolutely hate regular expressions because I suck at writing them...but I can help you with the logic. I was thinking search for a pattern which matches HREF=" + any number of characters + ". Your match would be HREF="blahblahblah". Then, you could go and chop off the HREF=" and the lagging ", and then you are left with just a URL. Then, you can use that built in url parser function (I forget its name, I think it might be urlparse()). Then, see if there is no host, it's obviously a relative link, otherwise, you can just see if the host matches or not. This should work well. Good luck -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 19, 2002 6:59 PM To: '[EMAIL PROTECTED]'; php Subject: RE: [PHP] regexp on user supplied link reg.ex. something like (not tested): "]*>" this would give you the entire anchor tag, then go from there? or what about using the XML parsing routines, get it to find the anchors and give you it's attributes, then go from there? Martin -Original Message- From: Justin French [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 20, 2002 10:46 AM To: php Subject: [PHP] regexp on user supplied link Hi, I have a website which is based purely on user-added content. The problem with this is that some areas allow users to use links in the text, and it's difficult to ensure that they all have a decent knowledge of attributes such as tartget="_new", etc etc. So, I'd like a script that... 1. looks at $text for any link tags, and for each tag, does the following: 2. throws out everything except the HREF eg: http://www.somesite.com"; target="_new">click becomes http://www.somesite.com becomes javascript:something(); 3. prefixe the url with http://www.mysite.com OR http://mysite.com"; is an external link. 5. if it's an external link, suffix the URL with " TARGET="_new">, or if it's internal, suffix it with "> Anyway, that'd be a great start. From there, I might like to prex each external link to go thru a program called out.php to log affiliate activity, and I might like to retain onmouseover, onclick, onmouseout etc etc properties in the tag, I might like to ensure a session ID is found within each internal link, and stripped from each external link, ensure that the has a matching etc etc, but the above would be a great start. Any help, especially with steps 1, 2 & 4, would be much appreciated. Thanks in advance, Justin French http://indent.com.au http://soundpimps.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp on user supplied link
I'll offer the following code to get you started on the task - and invite critiques/improvements! (cribbed from various sources and 'tuned' - note that either apostrophes or double quotes can be used to delimit the URL) $bValidity = $iFound = preg_match_all( "/(href *= *['\"]?)([^'\" >]*)(['\" >])/i", $HTML, $aRegExOut ); if ( 0 < $iFound ) { $aA = $aRegExOut[2]; if ( DEBUG ) { ShowList( "Located", $aA ); } BTW I'm covering a case of finding multiple links in one piece of HTML. This can be dialed-back for single cases. The rest I'll leave to you. Regards, =dn - Original Message - From: "SpamSucks86" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: 20 February 2002 21:16 Subject: RE: [PHP] regexp on user supplied link > I absolutely hate regular expressions because I suck at writing > them...but I can help you with the logic. I was thinking search for a > pattern which matches HREF=" + any number of characters + ". Your match > would be HREF="blahblahblah". Then, you could go and chop off the HREF=" > and the lagging ", and then you are left with just a URL. Then, you can > use that built in url parser function (I forget its name, I think it > might be urlparse()). Then, see if there is no host, it's obviously a > relative link, otherwise, you can just see if the host matches or not. > This should work well. Good luck > > -----Original Message- > From: Martin Towell [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, February 19, 2002 6:59 PM > To: '[EMAIL PROTECTED]'; php > Subject: RE: [PHP] regexp on user supplied link > > reg.ex. something like (not tested): > "]*>" > this would give you the entire anchor tag, then go from there? > > or what about using the XML parsing routines, get it to find the anchors > and > give you it's attributes, then go from there? > > Martin > > -Original Message- > From: Justin French [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, February 20, 2002 10:46 AM > To: php > Subject: [PHP] regexp on user supplied link > > > Hi, > > I have a website which is based purely on user-added content. The > problem with this is that some areas allow users to use links in the > text, and it's difficult to ensure that they all have a decent knowledge > of attributes such as tartget="_new", etc etc. > > So, I'd like a script that... > > 1. looks at $text for any link tags, and for each tag, does the > following: > > 2. throws out everything except the HREF eg: > http://www.somesite.com"; target="_new">click becomes > http://www.somesite.com > becomes javascript:something(); > > 3. prefixe the url with content is user-driven, I'd like to be a little safer, and say "anything > that begins with http://www.mysite.com OR http://mysite.com"; is an > external link. > > 5. if it's an external link, suffix the URL with " TARGET="_new">, or if > it's internal, suffix it with "> > > > Anyway, that'd be a great start. From there, I might like to prex each > external link to go thru a program called out.php to log affiliate > activity, and I might like to retain onmouseover, onclick, onmouseout > etc etc properties in the tag, I might like to ensure a session ID is > found within each internal link, and stripped from each external link, > ensure that the has a matching etc etc, but the above would be > a great start. > > > Any help, especially with steps 1, 2 & 4, would be much appreciated. > > > Thanks in advance, > > Justin French > http://indent.com.au > http://soundpimps.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp on us tele number
On Thursday 22 March 2001 16:17, you wrote: > i'm still getting the hang of regexps, however i have on small problem > - I can't seem to make one to work on a US telephone number. does > anyone have something similar that i could work from? Well, how does/can a US telephone number look like? -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) "Never doubt that a small group of thoughtful, committed people can change the world... Indeed, it's the only thing that ever has." - Margaret Mead -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] regexp. king needed (is it possible ???)
$content = ''; $new_str = '' > -Original Message- > From: Jeroen Olthof [mailto:[EMAIL PROTECTED]] > Sent: 17 iulie 2001 17:38 > To: [EMAIL PROTECTED] > Subject: [PHP] regexp. king needed (is it possible ???) > > > ereg_replace("$opentag([^*]*)$closetag", > $this->OPENTAG.$loopHandle.$this->CLOSETAG, $template); > > how do I get al hold on the "\\1" part of the replacement. > basicly I want to replace > > opentag1 .any content in between .. closetag1 > > with > > opentag2 onewordonly closetag2 > > but still need the > > .any content in between .. > > is this possible in some way ??? > > kind regards > Jeroen Olthof > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: > [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] regexp. king needed (is it possible ???)
thanks my king :) it works !!! "Adrian Ciutureanu" <[EMAIL PROTECTED]> schreef in bericht [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... $content = ''; $new_str = '' > -Original Message- > From: Jeroen Olthof [mailto:[EMAIL PROTECTED]] > Sent: 17 iulie 2001 17:38 > To: [EMAIL PROTECTED] > Subject: [PHP] regexp. king needed (is it possible ???) > > > ereg_replace("$opentag([^*]*)$closetag", > $this->OPENTAG.$loopHandle.$this->CLOSETAG, $template); > > how do I get al hold on the "\\1" part of the replacement. > basicly I want to replace > > opentag1 .any content in between .. closetag1 > > with > > opentag2 onewordonly closetag2 > > but still need the > > .any content in between .. > > is this possible in some way ??? > > kind regards > Jeroen Olthof > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: > [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] regexp question - extracting wanted ascii characters only?
On Wednesday 04 April 2001 11:23, you wrote: > Is it possible through the regexp to specify that I > only want some of the ASCII characters from the binary > stream? Here is the perl equivalent: > > /([\040-\176\s]{3,})/g > > I want only those words that are minimum 3 characters > and I want the characters to match the ASCII numbers > from 40 to 176. Why do you ask if you already have the solution? man preg_match -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence. - Edsger W. Dijkstra -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] regexp question - extracting wanted ascii characters only?
> From: Erick Papadakis [mailto:[EMAIL PROTECTED]] > > Hi, > > I need to do a simple thing. I want to read a binary > file (e.g., microsoft word, excel etc) and then > extract only the text from it. I am using simple > fopen() and fread() and when I print out the contents > of the file, it returns me the text but apart from the > text, there is some junk which is probably because of > the file being binary. > > Is it possible through the regexp to specify that I > only want some of the ASCII characters from the binary > stream? Here is the perl equivalent: > > /([\040-\176\s]{3,})/g > > I want only those words that are minimum 3 characters > and I want the characters to match the ASCII numbers > from 40 to 176. > You can use the regex likewise to perl. Try it here: http://www.php.comzept.de/rexpr/index.php4 Instead of the /g option use the function preg_grep() in PHP. Read the file in an array with file(), then grep through the array with the regex to get the right lines. Want a string? implode() without delimiter. Joerg Krause ** E-Mail: [EMAIL PROTECTED] Info:www.joerg.krause.net German Reference Handbook: www.php.comzept.de/referenz ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]