PHP - basic phone number validation [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I'm trying to validate for UK phone numbers - the specific requirements I have are:
must only consist of digits
the only non-digit characters allowed are space and dash
must begin with a zero
Can anyone suggest a nice and simple regular expression I can use for this?

Try with following regex:
^0([ -]\d+)*\d+$

Related

How to replace everything outside of quote marks? - REGEX Komodo Edit/Notepad++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Could somebody tell me the regular expression for replacing everything outside of quote marks with white space?
Example text :
permalink_title='$permalink_title',
code_size_3='$code_size_3',
code_size_3='$code_size_3',
code_size_35='$code_size_35',
code_size_4='$code_size_4',
code_size_45='$code_size_45',
code_size_5='$code_size_5',
code_size_55='$code_size_55',
code_size_6='$code_size_6',
code_size_65='$code_size_65',
code_size_7='$code_size_7',
code_size_75='$code_size_75',
code_size_8='$code_size_8',
code_size_85='$code_size_85',
code_size_9='$code_size_9',
code_size_95='$code_size_95',
code_size_10='$code_size_10',
code_size_105='$code_size_105',
So the expression would replace everything outside of '$permalink_title' with whitespace. Ideally it would go one better and replace everything with whitespace leaving only the PHP variable - $permalink_title
*Note - I was going to perform this function with Komodo Edit or Notepad++
Any help would be great.
Use this regex :
(^[^']+|(?<=')[^']+$)
Debuggex Demo

PHP superscript [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Is there any way that I can get o identify characters like(trademark, superscripts, numbers) from text or text file(but these characters are't in HTML code) and replace them using php
Example:
Get from text: ™ replace with PHP: (TM)
Yes, just parse your strings with str_replace.
Note that str_replace can use arrays, so you can replace multiple strings at once:
$text = "Text™®";
$text = str_replace(['™', '®'], ['(TM)', '(R)'], $text);
print $text;

Allow letters, digits and certain characters and delete the rest [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
when user submit a form input text
i want it just to allow a-z 0-9 and -_ just this numbers digits and -_
how do i check the input and make it only this inputs allows and delete the rest
Thank You!
$output = preg_replace("/[^a-zA-Z0-9_\-]/", '', $input);
function validate($value){
return preg_match("/^[a-zA-Z0-9_\-]*$/", $value) !== 0;
}
If the return value is false then you have invalid characters, if it true, everything is correct.
$input = preg_replace("/[^0-9a-z\_\-]/i", "", $_POST["myfield"]);
Use regexp.

Convert excel formula to php [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I rent out caravans and am looking to offer pay monthly options.
We have worked out a formula in Excel but need to convert it to PHP.
The excel formula is:
monthlyCost=SUM("holidayCost"/(roundDown(((("holDate"-30)-"todaysDate")/30),0)))
The problem is rounding the number down.
Can anyone help?
round((( $holDate - 30 - $todaysDate)/30), 0, PHP_ROUND_HALF_DOWN);

Php regex for number with point after each three digits [closed]

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 to make a number validation that checks if the user hasn't already added the points after each three digits. I plan to do this verification using refex
So for example 11.231.121.313 is a valid number, also 11231121313 but 11231.121.313 is not.
^(\d+|\d{1,3}(\.\d{1,3})*)$
The first alternation allows you to have simply all digits. The second checks for 1-3 digits optionally followed by groups of a decimal point with 1-3 following digits. This works for your examples.
try this
if (preg_match('/^(\d{1,3}(\.\d{3})+|\d+)$/', $number)) {
// correct number
}
UPD: Add expression for only numbers

Categories