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
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 need one regex which validates below condition for password entered by user:
it must have at least one capital letter
it must have at least one number
It must have at least one special character
I need regex to implement it in javascript.
I have tried this one
/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!##$%^&*()_+|~-=\`{}[]:";'<>?,])/i;
Thanks in Advance
For the rules you mentioned:
/^(?=.*[0-9])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])/;
This should suffice.
[^a-zA-Z0-9] matches anything that is not an alphabet and not a number, i.e. a special character.
I removed the case insensitive flag because you specifically mentioned there should be 1 uppercase letter.
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
i want to ignore all special character but "-" and non-english characters on key press in jquery. Actually this input is used to check domain availability. like;
www.________.com | for and end extensions are already provided for user. they won't enter those parts.
can you help?
You should use a onChange event, since users can also paste something into the field.
To check if the string is a valid url, use this pattern
var urlPattern = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,#?^=%&:\/~+#-]*[\w#?^=%&\/~+#-])?/