Javascript regular expression to validate Facebook URL's [closed] - javascript

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 regular expression in javascript that can validate all the patterns of Facebook URL's.
I have tried some of the regular expressions but i am not satisfied with those regular expression's completely.
Also i want in regular expression is that,it should take/accept the facebook url's without:
http,https or www.
Means it should accept:
facebook.com/....
www.facebook.com/...
http://facebook.com/....
https://facebook.com/...
Please suggest me the regular expression that can validate all of the URL patterns of Facebook in javascript.
Thanks

Hacked this very quick and it seems to cover your cases:
(?:(?:http|https):\/\/)?(?:www.)?facebook.com\/?

I think this should be good enough
/^(https?:\/\/){0,1}(www\.){0,1}facebook\.com/

Related

Javascript Regex replace string between 2 strings [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'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

Replace Js Variables names using PHP [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 search about protect my javascript code by changing his variable names (complicate the code lisibility like on jQuery).
i find jasob application and i like it because it change maximum variables compared with other system like jscompress
i want to create php code that can transform maximum of varibles and put the compared in database to reverse action, it's seems to be very difficult to do.
Can someone know a existant code like this have proposition to simplify?
protect my javascript code
I don't think that is practically possible. JavaScript is rendered on Client-Side, so no matter you do security, the JS files still going to be downloaded on the client-machine.

Regex for domain name only [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'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,})/?

how to escape special and non-english characters on key press? [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 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#?^=%&\/~+#-])?/

Javascript regexp replace sub-word [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 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

Categories