The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Telling the difference between space bar and return key
Code:
$_POST['xtraimg'] = trim(preg_replace('#\s+#si', ' ', $_POST['xtraimg'])); The above code strips all spaces completely out, only leaving one like it should. However it removes spaces for paragraphs also. Is there a way a code can tell the difference between a spacebar space and a return/enter key newline/space? |
#2
|
||||
|
||||
code looks better now
|
#3
|
|||
|
|||
you can probably use a class of characters instead of \s if you don't want \n (newline) to be matched.
try using [\x20] instead of \s if you just want to match spaces. so, your code would look like Code:
$_POST['xtraimg'] = trim(preg_replace('#[\x20]+#si', ' ', $_POST['xtraimg'])); |
#4
|
||||
|
||||
cool, thanks
I'll give it a shot! edit: I found a use for this in vb also |
#5
|
|||
|
|||
heh, relooking at my code... you don't need the braces ['s ]'s
\x20+ will work just fine too... don't know what I was thinking |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|