Jump to content

error massage


xbl1

Recommended Posts

Hi;Could anyone debug for me, please.Warning: preg_replace() [function.preg-replace]: Unknown modifier 'a' in index.php on line 6my code as following;

<?php //line 1$str=' test & me ';$p='^[^a-z]+$';$r='_';$str=preg_replace($p, $r, $str); // here is line 6echo $str;?>
Link to comment
Share on other sites

$p should be equal to $p='^[a-z]+$';, there is no character set [^a-z]. But what are you trying to do?

Link to comment
Share on other sites

$p should be equal to $p='^[a-z]+$';, there is no character set [^a-z]. But what are you trying to do?
i am trying to replace all the chars which more than one, but without chars which are a-z, by using '_'.for example;' test & O me 98877 . 'become to '_test_me_'could you help me, please.
Link to comment
Share on other sites

Hmm... maybe... don't know what it does though lolRemember, PHP's Regex engine is different from JavaScript's Regex engine.

i am trying to replace all the chars which more than one, but without chars which are a-z, by using '_'.
I'm not very good at Regular Expressions, but one solution would be to include all characters that you do not want:
$p = "[0-9A-Z.-_\s\\/!@#$%^&*()+=\[\]\"'{}|<>?,./~`]+";

However that is sort of inefficient.

Link to comment
Share on other sites

Hmm... maybe... don't know what it does though lolRemember, PHP's Regex engine is different from JavaScript's Regex engine.I'm not very good at Regular Expressions, but one solution would be to include all characters that you do not want:
$p = "[0-9A-Z.-_\s\\/!@#$%^&*()+=\[\]\"'{}|<>?,./~`]+";

However that is sort of inefficient.

Thanks a lot, i have found out the solution already.$p='#[^a-z]+#';
Link to comment
Share on other sites

by the way, I've been dieing to ask - how was your error massage? Is it anything like a deep tissue massage? What region does it focus on - upper or lower back . . .? I'll have to ask my masseuse if she offers error massages.:)

Link to comment
Share on other sites

don't know what it does though lol
[^a-z] matches any character that is not in the set of "a" through "z". It's the exact opposite of [a-z].
Link to comment
Share on other sites

I'd make jokes too, except for i do that too. Message, massage... it took me the longest time to figure out the difference. I feel your pain man, i feel your pain.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...