Mathias Brodala: preg_replace regex problem

Beitrag lesen

Hallo Tobias.

immer nach einem doppelpunkt soll nämlich einen (auch nicht mehrere) abstand sein.
ich weiss dass es mit der funktion preg_replace() möglich ist, doch blicke ich beim regulären ausdruck noch nicht wirklich durch.
Einen regulären Ausdruck braucht man dafür garnicht

Doch, hier ist einer erforderlich.

  • ein einfaches

$str = 'color:#000;';

$str = str_replace(':',': ',$str);
echo $str; // gibt "color: #000;" aus


> reicht völlig.  
  
Dann würde aus folgendem:  
  
~~~css
a:hover {  
  color:#069;  
  content:': Foo';  
}

Folgendes:

a: hover {  
  color: #069;  
  content: ':  Foo';  
}

Dies ist ganz gewiss nicht erwünscht.

Einen schönen Montag noch.

Gruß, Mathias

--
sh:( fo:} ch:? rl:( br: n4:~ ie:{ mo:| va:) de:> zu:} fl:( ss:) ls:[ js:|
„It is required that HTML be a common language between all platforms. This implies no device-specific markup, or anything which requires control over fonts or colors, for example. This is in keeping with the SGML ideal.“
[HTML Design Constraints: Logical Markup]