Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a PHP Variable which i need to remove all special characters from, like % / é / ! etc
how can i replace all characters OTHER than A-Z / a-z / 0-9 and . (full stop) with a _
Something like this ought to work.
preg_replace("/[^A-Za-z0-9\.]/", "_", $str);
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How do I remove characters till there comes another character in a string?
For example:
String is this: 0030051
Now I want to remove ALL 0's before another character (like: 1) comes.
So the string will become this: 30051.
Is there a PHP function for this or is this easier with Javascript/jQuery ? (I'd prefer PHP)
cast it to integer
$var = (int)$var;
Source - Reference
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to create a regex that will select the data between two characters (& - #).
& foo #
I would like to select foo.
Any ideas? Good explanations are also appreciated.
how about this:
preg_match('~&([^#]*)#~',$content,$match);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want a regex that will help me to get the 4 numbers before the cc.
The RegEx must contain the cc to identify these exact number.
Example:
1600cc
You should use:
/(\d{4})cc\b/
\b ensures that "cc" is at the and of the word.
preg_match('/(\d{4})cc/', $string, $match);
$match[1] will contain the number.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want allow this file name type:
A-Z letters
a-z letters
1-x numbers
Special character: "(" ")" "-"
If you can help me with preg_match rules I was tried but without success.
<?php
$filename = "A-(";
if(preg_match("/^[A-Za-z0-9-\(\)]+$/", $filename)) {
echo "matched";
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Can someone explain the difference between these two lines of code?
preg_replace("/[^0-9]/", '', $Phone);
preg_replace('/[^0-9\/+]/', '', $Phone);
Ive been hunting online and cant seem to find anything explaining the extra "/+"
The following matches anything that's not a digit.
/[^0-9]/
The following matches anything that's not a digit, /, or +:
/[^0-9/+]/