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
Regular Expression to validate the turkey phone number either in php or js
Example : +90 (212) 123 12 12
Try this : http://www.txt2re.com/index-javascript.php3?s=%2b90%20(212)%20123%2012%2012&28&17&22&18&23&19&24&27&20&25&21&26
I often use this site to do my regex. It generates code in the language you want.
Just edit what's inside the "if" once you copied the code. Magic.
try this, it should work in php environment
^\+(\d{2})\s\((\d{3})\)\s(\d{3})\s(\d{2})\s(\d{2})
DEMO
javascript...
var testNumber = "+90 (212) 123 12 12";
testNumber.replace(/\D+/g,"").matches(/90\d{10}/);
that eliminates all non digit chars and then makes sure that you have 90 followed by 10 digits
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
I'm trying to figure out the best way to replace a string between 2 other strings. I believe regex is necessary for this.
Input string:
"http://domainabc.com/dir1/dir2"
Output string:
"http://domainxyz.com/dir1/dir2"
Only the domain will change - not the subdirectories.
Probably you're looking to change current domain name without bothering what the domain is. Try this code:
var s = "http://domainabc.com/dir1/dir2";
repl = s.replace(/\b(https?:\/\/)[^/]+(.+)$/, "$1domainxyz.com$2");
//=> http://domainxyz.com/dir1/dir2
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'm asking my users to write their domain name.
I'm looking for inputs of these types (=good):
http://www.Domain.com
http://Domain.com
https://www.Domain.com
https://Domain.com
www.Domain.com
Domain.com
http://no.matter.how.many.Domain.com
https://no.matter.how.many.Domain.com
no.matter.how.many.Domain.com
http://www.Domain.com/
https://www.Domain.com/
http://no.matter.how.many.Domain.com/
https://no.matter.how.many.Domain.com/
www.Domain.com/
Domain.com/
I'm want to reject any input that not in this format.
Bad inputs, for example:
http://www.Domain.com/page
http://www.Domain.com/page.html
http://www.Domain.com/page/page2
and so on...
Can you help me with a suitable RegEx?
Thank you!
You can use this regex
^(https?://)?[^/]+/?$
^depicts the start of string
$ depicts the end of string
? matches preceding group or char optionally..
Solution:
(https?://)?(www.)?([A-Za-z]+\.){1,}([A-Za-z]{2,})/?
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 this original code. Can I know what is the meaning of this code? I confuse a bit.
if (/^\d{5}(-\d{4})?$/.test(zip.value)) {
I need to rewrite to zip code with 6 numeric digit excluding space. How should I do?
you can find your explanation here: http://rick.measham.id.au/paste/explain.pl?regex=%2F%5E%5Cd%7B5%7D%28-%5Cd%7B4%7D%29%3F%24%2F
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
Suppose I have a number like 1234. I want to add new number 00 and , and € at the end. Now number will be like 1234,00€ I can not figure out.
That will work for you:
var value = '1234';
var formatted = value.replace(/(\d+)/, '$1,00€');
But, I strongly recommend you to read the answers in this question: How can I format numbers as money in JavaScript?
Update as #jared said, you can just concatenate the text: ,00€ to your number to just get the desired results.
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 use JavaScript regexp replace text below:
i love #HTC & #HTC-One
to
i love #HTC & HTC-One
var result = "i love #HTC & #HTC-One".replace(
/#([\w-]+)/g,
'#$1');
The regex looks for words that start with # alpha numeric and -.
The word without the # is enclosed in parenthesis to make it a capturing group.
The capturing group is referenced in the replacement with $1