[PHP] Remove Dynamic String between StringA and StringB

2004-01-27 Thread Jack Bauer
Hi :),

i tried your code zu replace some parts of a string,
the problem is that this method only replaces when
there is only 1 word between stringA and stringB.
i got the problem that the part between both strings
is a dynamic one and much larger then 1 word.
i really tried to use the php manual and google
to find some help for this, but i got no luck with that :(

$stringA = AA;
$stringB = BB;
$string = AA oneword BB AA two words BB;

$pattern = /$stringA.\w*.$stringB/;
$replacement = ;
echo preg_replace($pattern, $replacement, $string);

i think it have to do something with the \w in the pattern,
is there a parameter to resolve my problem too?


regards
manuel

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Remove Dynamic String between StringA and StringB

2004-01-27 Thread Martin Luethi
$pattern = /$stringA.*?$stringB/;

.*? - matches everything between $stringA and $stringB
  the ? means: stop matching after the first occurence
  of $stringB (quantifier minimizer). otherwise .* would
  match everything between the first occurence of $stringA
  and the last occurence of $stringB
- http://ch2.php.net/manual/de/pcre.pattern.syntax.php

g. tinu

Tue, 27 Jan 2004 13:25:27 +0100 Jack Bauer [EMAIL PROTECTED]:

Hi :),

i tried your code zu replace some parts of a string,
the problem is that this method only replaces when
there is only 1 word between stringA and stringB.
i got the problem that the part between both strings
is a dynamic one and much larger then 1 word.
i really tried to use the php manual and google
to find some help for this, but i got no luck with that :(
$stringA = AA;
$stringB = BB;
$string = AA oneword BB AA two words BB;
$pattern = /$stringA.\w*.$stringB/;
$replacement = ;
echo preg_replace($pattern, $replacement, $string);
i think it have to do something with the \w in the pattern,
is there a parameter to resolve my problem too?
regards
manuel
--
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] Remove Dynamic String between StringA and StringB

2004-01-27 Thread memoimyself
On 27 Jan 2004 at 13:25, Jack Bauer wrote:

 i tried your code zu replace some parts of a string,
 the problem is that this method only replaces when
 there is only 1 word between stringA and stringB.

Of course. \w* will match alphanumeric characters, but not whitespace, and word 
boundaries are typically whitespace.

 i really tried to use the php manual and google to find some help for
 this, but i got no luck with that :( 

It's not a question of luck; it's a question of investing a little of your time in 
reading and 
learning. You don't want to spend your time doing that but expect other people to 
spend 
theirs providing you with all the answers you need. You've been given a few pointers 
(such as the online introductory guide to regular expressions, which will tell you 
everything about matching word characters, non-word characters etc etc) but don't 
seem to have taken any interest in them, because of course that would mean you'd 
have to actually spend an hour or so of your valuable time doing some reading. Bear in 
mind that other people's time is *also* valuable.

 i think it have to do something with the \w in the pattern, 
 is there a parameter to resolve my problem too?

Go to http://msdn.microsoft.com/library/en-
us/script56/html/js56reconIntroductionToRegularExpressions.asp and read it, especially 
the Regular Expression Syntax section. After doing that, read the relevant part of the 
PHP manual. Things will start to make sense soon enough.

Erik

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Remove Dynamic String between StringA and StringB

2004-01-26 Thread Jack Bauer
Hi :),

i'm looking for a function to remove multiple dynamic parts
of a string, there are only the start and end strings given

(remove all between string A and string B)

got somebody a working procedure for that?


regards

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Remove Dynamic String between StringA and StringB

2004-01-26 Thread memoimyself
Hello 24 fan,

On 27 Jan 2004 at 0:56, Jack Bauer wrote:

 i'm looking for a function to remove multiple dynamic parts
 of a string, there are only the start and end strings given
 
 (remove all between string A and string B)
 
 got somebody a working procedure for that?

I'm not sure I understand you correctly, but it seems to me that you need to use 
regular 
expressions. You haven't provided us with an example or with strings A and B, so 
it's 
kinda difficult to give you any specific help. Suggestion: read up on Regular 
Expression 
Functions (Perl-Compatible) in the PHP manual (chapter XC in the Function Reference 
section).

If you're not familiar with regular expressions and find the PHP manual too difficult 
as a 
starting point, you'll find a pretty good introductory guide, courtesy of the Dark 
Side of 
the Force, at  

http://msdn.microsoft.com/library/en-us/script56/html/js56reconIntroducti 
onToRegularExpressions.asp  

Have fun,  

Erik

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Remove Dynamic String between StringA and StringB

2004-01-26 Thread Matt Matijevich
snip
Hi :),

i'm looking for a function to remove multiple dynamic parts
of a string, there are only the start and end strings given

(remove all between string A and string B)

got somebody a working procedure for that?


regards
/snip

a start of a procedure I have

$stringA = string A;
$stringB = string B;
$string = remove all between string A and string B;


$pattern = /$stringA.\w*.$stringB/;
$replacement = $stringA$stringB;
echo preg_replace($pattern, $replacement, $string);




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php