I'm putting together a website into which I am incorporating a form of BBCode. I want to use str_replace() to replace the BBCode with the appropriate HTML (or whatever) whenever the page is displayed, as apparently str_replace is quite fast (at least compared to ereg_replace).
However, str_replace is case sensitive. I want people to be able to use caps or lower case as they wish within the BBCode. Is there any way around this? Is there a way to make str_replace case sensitive? If not, I'm happy enough using preg_replace, but apparently that's canse sensitive too. Am I stuck with eregi_replace?
Regex and case sensitivity
Moderator: General Moderators
- ILoveJackDaniels
- Forum Commoner
- Posts: 43
- Joined: Mon May 20, 2002 8:18 am
- Location: Brighton, UK
- ILoveJackDaniels
- Forum Commoner
- Posts: 43
- Joined: Mon May 20, 2002 8:18 am
- Location: Brighton, UK
- ILoveJackDaniels
- Forum Commoner
- Posts: 43
- Joined: Mon May 20, 2002 8:18 am
- Location: Brighton, UK
Is the following likely to work at any reasonable speed?
Code: Select all
$haystack=str_replace($needle, $replacement, strtolower($haystack));preg_match can be used insensitively (iU or something).
Or just echo a string - my preferred method:
Or just echo a string - my preferred method:
Code: Select all
<?php
echo 'BB tags must be lower case.';
?>