RE: [PHP] Regex question: replacing incidences of character when not enclosed within HTML tags? (somewhat solved)

2005-05-29 Thread Murray @ PlanetThoughtful
> So, thinking about it a little more, I decided what I was looking for was > a > regular expression that would allow me to replace any incidences of > hyphens > when not contained within tags (i.e., when not contained between "<" and > ">"). > > And this is where things have ground to a halt. Hi

[PHP] Regex question: replacing incidences of character when not enclosed within HTML tags?

2005-05-28 Thread Murray @ PlanetThoughtful
Hi All, I have content that contains several lengthy hyphenated sentences, such as: This-is-a-sentence-in-which-all-the-words-are-hyphenated. I've noticed that some (maybe all?) browsers, particularly Firefox, will not wrap long strings of hyphenated words when they are contained in a DIV tag --

Re: [PHP] regex question

2005-05-17 Thread Al
Murry's solution here is ideal since it only captures the single occurrence. Since I want to use it for a preg_replace(), it is perfect. A couple of folks sent this pattern [EMAIL PROTECTED]@[EMAIL PROTECTED]; but, it doesn't work because I then have to remove the unwanted caracters on either si

Re: [PHP] regex question

2005-05-17 Thread Petar Nedyalkov
On Monday 16 May 2005 22:53, Al wrote: > What pattern can I use to match ONLY single occurrences of a character in a > string. > > e.g., "Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@. Use the following: /(^@)(@{1})(^@)/ This way you'll be sure the regexp will match only single occu

Re: [PHP] regex question

2005-05-16 Thread Jason Barnett
$text = 'Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@.'; /** Word boundaries before and after @ */ $regex = '/[EMAIL PROTECTED]/'; preg_match_all($regex, $text, $matches); var_dump($matches); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.n

RE: [PHP] regex question

2005-05-16 Thread Murray @ PlanetThoughtful
> Try (for example if character was "A") ... > > ([^A]|^)A([^A]|$) > > This matches four cases: > A is at beginning of string and there is another letter after it, > A has a letter before it and a letter after it, > A is at end of string and there is a letter before it, > or A is the only charact

RE: [PHP] regex question

2005-05-16 Thread Murray @ PlanetThoughtful
> What pattern can I use to match ONLY single occurrences of a character in > a string. > > e.g., "Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@. > > I only want the two occurrences with a single occurrence of "@". > > @{1} doesn't work; there are 4 matches. > > Thanks Please

RE: [PHP] regex question

2005-05-16 Thread Murray @ PlanetThoughtful
> What pattern can I use to match ONLY single occurrences of a character in > a string. > > e.g., "Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@. > > I only want the two occurrences with a single occurrence of "@". > > @{1} doesn't work; there are 4 matches. "/[EMAIL PROTECTED]@[EM

Re: [PHP] regex question

2005-05-16 Thread Philip Hallstrom
On Mon, 16 May 2005, Al wrote: What pattern can I use to match ONLY single occurrences of a character in a string. e.g., "Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@. I only want the two occurrences with a single occurrence of "@". [EMAIL PROTECTED]@[EMAIL PROTECTED] should do it I

Re: [PHP] regex question

2005-05-16 Thread Brandon Ryan
Try (for example if character was "A") ... ([^A]|^)A([^A]|$) This matches four cases: A is at beginning of string and there is another letter after it, A has a letter before it and a letter after it, A is at end of string and there is a letter before it, or A is the only character in the string.

[PHP] regex question

2005-05-16 Thread Al
What pattern can I use to match ONLY single occurrences of a character in a string. e.g., "Some text @ and some mo@@re and [EMAIL PROTECTED], etc @@@. I only want the two occurrences with a single occurrence of "@". @{1} doesn't work; there are 4 matches. Thanks -- PHP General Mailing List (ht

Re: [PHP] REGEX Question

2003-06-18 Thread SLanger
Hello Two things: First wouldn't it be faster to use strpos and substr if you simply have to find the literate and . Second: If you use your regex and you have something like " This is some text to grasp this is text I don't want This is some other text I want" The result would be " This is so

Re: [PHP] REGEX Question

2003-06-18 Thread Don Read
On 17-Jun-2003 Ron Dyck wrote: > I need to match text between two html comment tags. > > I'm using: preg_match("/(.*)/", $data, > $Match) > > Which work fine until I have carriage returns. The following doesn't > match: > Use the m (multiline) modifier: preg_match("/(.*)/m", ... Regards, --

Re: [PHP] REGEX Question

2003-06-17 Thread Marek Kilimajer
. matches any character except newline by default, use s modifier: preg_match("/(.*)/s", $data, $Match) Ron Dyck wrote: I need to match text between two html comment tags. I'm using: preg_match("/(.*)/", $data, $Match) Which work fine until I have carriage returns. The following doesn't match:

[PHP] REGEX Question

2003-06-17 Thread Ron Dyck
I need to match text between two html comment tags. I'm using: preg_match("/(.*)/", $data, $Match) Which work fine until I have carriage returns. The following doesn't match: Nullam auctor pellentesque sem. Aenean semper. Aenean magna justo, rutrum et, consequat a, vehicula non, arcu. Mauris c

[PHP] regex question?

2003-02-23 Thread Shawn McKenzie
I'm using the following to try and replace urls in my html output: $newhrefs = preg_replace("/script.php\?(.*)=(.*)&(.*)=(.*)&(.*)=(.*)/", "script-$1-$2-$3-$4-$5-$6.html", $hrefs); This works fine as long as there are exactly 3 var=val pairs... not 1 or 2 or 4 or more... How can I write my expre

Re: [PHP] Regex question

2002-12-13 Thread Sean Burlington
Troy May wrote: How would take a regular non-formatted text link (http://www.link.com) and turn it into ready to post HTML? (http://www.link.com>http://www.link.com) Darn, Outlook formats it, but you get the idea. It would just be typed out normally. Any ideas? function MakeUrl ($text) {

[PHP] Regex question

2002-12-12 Thread Troy May
How would take a regular non-formatted text link (http://www.link.com) and turn it into ready to post HTML? (http://www.link.com>http://www.link.com) Darn, Outlook formats it, but you get the idea. It would just be typed out normally. Any ideas? -- PHP General Mailing List (http://www.php.net

Re: [PHP] Regex question...

2002-10-28 Thread Leif K-Brooks
I need to do a few other things that require regex though, like making either an a or an @ match (people love to get around filters by using symbols instead of letters...). @ Edwin wrote: Hello, "Leif K-Brooks" <[EMAIL PROTECTED]> wrote: [snip] But that doesn't work at all. Any ideas on h

Re: [PHP] Regex question...

2002-10-28 Thread @ Edwin
Hello, "Leif K-Brooks" <[EMAIL PROTECTED]> wrote: [snip] > But that doesn't work at all. Any ideas on how to do this? [/snip] Would't it be easier (and faster) to use http://www.php.net/manual/en/function.str-replace.php ? - E -- PHP General Mailing List (http://www.php.net/) To unsubsc

[PHP] Regex question...

2002-10-28 Thread Leif K-Brooks
In my never-ending battle against swearing on my site, I'm trying to use a regex that changes any word that ends with abc to xyz. I'm using: $tofilter = "This is a string containing the word 123abc."; $tofilter= eregi_replace("[^ ]abc","xyz",$tofilter); But it returns "12xyz". It clearly pick

Re: [PHP] RegEx question

2002-07-02 Thread Gurhan Ozen
eregi("php$", $stringtobecompared); See: http://www.php.net/manual/en/ref.regex.php Gurhan - Original Message - From: "David Busby" <[EMAIL PROTECTED]> To: "php-general" <[EMAIL PROTECTED]> Sent: Tuesday, July 02, 2002 4:49 PM Subject: [PHP]

RE: [PHP] RegEx question

2002-07-02 Thread Henning Sittler
$string = 'somethingphp'; $pat = 'php$'; $hasphp = ereg($pat, $string); Henning Sittler www.inscriber.com -Original Message- From: David Busby [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 02, 2002 4:49 PM To: php-general Subject: [PHP] RegEx question Lis

Re: [PHP] RegEx question

2002-07-02 Thread Kevin Stone
; <[EMAIL PROTECTED]> Sent: Tuesday, July 02, 2002 2:49 PM Subject: [PHP] RegEx question > List, > How can I regex to compare the last three chars of a string to "php"? > > /B > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe,

[PHP] RegEx question

2002-07-02 Thread David Busby
List, How can I regex to compare the last three chars of a string to "php"? /B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Regex question

2002-01-09 Thread Jon Haworth
> As far as I can see (notice: I'm not a regex-king ;) the regex seems correct > to me. The only thing I'm wondering about is the "/^<" (second last line of > the citation). Together with your expression in the array it results in > preg_match("/<\/ I'm wondering if that ( not only

Re: [PHP] Regex question

2002-01-09 Thread Stefan Rusterholz
> > If you want the [ to be escaped in the regex you have to "double-escape" > it: > > $x = "\ \["; (sorry, the two \ should be together without a space but my > > stupid mail-app converts the string thinking it's an network address) > > so $x will contain "\[" as you want ( the first backslash e

RE: [PHP] Regex question

2002-01-09 Thread Jon Haworth
> If you want the [ to be escaped in the regex you have to "double-escape" it: > $x = "\ \["; (sorry, the two \ should be together without a space but my > stupid mail-app converts the string thinking it's an network address) > so $x will contain "\[" as you want ( the first backslash escapes the

Re: [PHP] Regex question

2002-01-09 Thread Stefan Rusterholz
> Hi all, > > I've got a regex that's working fine, apart from one little problem. > > $tags = array ("script", >""); A quick shot (perhaps I miss the point ;): if you do $x = "\["; then $x will contain "[". If you then do a regex with preg_match("/$x/", ..." eg. then it get's eva

[PHP] Regex question

2002-01-09 Thread Jon Haworth
Hi all, I've got a regex that's working fine, apart from one little problem. $tags = array ("script", ""); foreach ($tags as $currentTag) if (preg_match ("/^<\/". $currentTag. "/", $content)) // do something (checking to see if anything in the $tags array is at the start

Re: [PHP] Regex question

2001-07-31 Thread CC Zona
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Boaz Yahav) wrote: > In case anyone is interested, eregi("HTTP/1.[01].302",$output) seems to > work :) "." == "any character" (including, but not necessarily, a period). If you want to match a period, escape it or put it in square braces: e

RE: [PHP] Regex question

2001-07-31 Thread Boaz Yahav
In case anyone is interested, eregi("HTTP/1.[01].302",$output) seems to work :) berber -Original Message- From: Boaz Yahav Sent: Tuesday, July 31, 2001 2:03 PM To: PHP General (E-mail) Subject: [PHP] Regex question I'm trying to find if a string exists inside a str

[PHP] Regex question

2001-07-31 Thread Boaz Yahav
I'm trying to find if a string exists inside a string. Instead of using strstr() twice I want to use eregi() once. What I want to check is if "HTTP/1.1 302" or "HTTP/1.0 302" exists in some $output. I'm trying something like : eregi("[\"HTTP/1.\"]+[0-1]+[\" 302\"]",$output) eregi("[HTTP/1.]+[0

[PHP] regex question

2001-07-16 Thread Julian Simpson
I'm trying to parse an existing html file using php. I need to use regex to find the first (and only the first) occurance of and the last (and only the last) occurance of in a string. They will be replaced with ||. example of a string: blah blah some stuff that i need to get blah blah blah. n

Re: [PHP] RegEx Question

2001-05-21 Thread Gyozo Papp
Sent: 2001. május 20. 19:18 Subject: [PHP] RegEx Question > Hi, > > I have an ereg question::. > $data = a big string , > while (ereg ("testing([^;]*);blah(.*)",$data,$args)) { > $this = $args[1]; > $data = $args[2]; > } > > What I wanna do ,obvi

Re: [PHP] RegEx Question

2001-05-20 Thread Christian Reiniger
On Sunday 20 May 2001 19:18, George E. Papadakis wrote: > I have an ereg question::. > $data = a big string , > while (ereg ("testing([^;]*);blah(.*)",$data,$args)) { > $this = $args[1]; > $data = $args[2]; > } > > What I wanna do ,obviously, is to get all the strings between 'testng' > a

[PHP] RegEx Question

2001-05-20 Thread George E. Papadakis
Hi, I have an ereg question::. $data = a big string , while (ereg ("testing([^;]*);blah(.*)",$data,$args)) { $this = $args[1]; $data = $args[2]; } What I wanna do ,obviously, is to get all the strings between 'testng' and 'blah' in an array. This will do it, yet when it wont work when sp