jQuery not work condition with Germany charset [duplicate] - javascript

This question already has answers here:
Javascript string comparison fails when comparing unicode characters
(5 answers)
Closed 8 years ago.
I have problem with condition of Germany charset:
if (jQuery(this).find("dt").text()=="Kälteleistung")
Its always return false but in jQuery(this).find("dt").text() alert print Kälteleistung

if(jQuery(this).find("dt").text()==jQuery("<div/>").html("Kälteleistung").t‌​ext())
This simple solution help me. There are we are find special char of ä char. We are formed string for condition "Kälteleistung" and our task is return string which be same as we take in our html. We are need place it to html jQuery("<div/>").html("Kälteleistung") and take it .t‌​ext(). Very simple and clear solution which does not require a third-party libraries.
Thanks!

I got your question working, without the need of extra stuff. I think your problem is in the selector not working good (there is no need to use find).
I have this sample, returning 'ok':
<div>Kälteleistung</div>
<script>
if ($("div").text()=="Kälteleistung")
{
alert('ok');
}
else
{
alert('not ok');
}
</script>

Related

javascript regexp surprise [duplicate]

This question already has an answer here:
Javascript RegEx Not Working [duplicate]
(1 answer)
Closed 5 years ago.
I tried the following JavaScript in developer console of Chrome:
s = "mysessionId=PsGymRfxWIQG9gjNGgRlKw"
s.match("mysessionId=([^\s\;]+)")
A little surprised by the result:
["mysessionId=P", "P"]
I had expected that the () in regexp will match the entire "PsGymRfxWIQG9gjNGgRlKw", instead, it only matched the first character "P".
When I tried the regexp in perl, it does match the entire sessionId.
Any idea why?
I should have used // instead of "".
s.match(/mysessionId=([^\s\;]+)/)
Had to laugh the moment when I figured it out.

regex to retrieve specific url from text [duplicate]

This question already has answers here:
Regular Expression to find a string included between two characters while EXCLUDING the delimiters
(13 answers)
Closed 7 years ago.
An API I use returns this text:
<http://192.168.1.10:8080/longUrl>; rel="recording-session",
<http://192.168.1.10:8080/realLongUrl>; rel="h264-session-sdp",
<http://192.168.1.10:8080/realLongDifferentUrl>; rel="h264-session-sdp",
<rtp://239.1.1.18:5006>; rel="destination-high",
<rtp://239.1.1.17:5006>; rel="destination-low"
I'm trying to retrieve the first URL that is followed by ; rel="h264-session-sdp.
So in this case that would be: http://192.168.1.10:8080/realLongUrl
I've been fiddling around trying to modify examples found here on SO, but just can's seem to get it right.
try this one /([^<]+)(?:>; rel\=\"h264\-session\-sdp\")/
Selects the text inbetween the greater then and less then characters:
?<=\<)(.*?)(?=>)
https://regex101.com/r/oS5sX6/1
And if you wanted to select the urls on multiple lines, add the g and m modifiers:
/(?<=\<)(.*?)(?=>)/gm
https://regex101.com/r/oS5sX6/2
Try this:
/(?<=\<)(.*?)(?=\>)>; rel="h264-session-sdp"/

replace asterisk innerhtml javascript [duplicate]

This question already has answers here:
How do I replace an asterisk in Javascript using replace()?
(6 answers)
Closed 8 years ago.
how do i replace the asterisks with a blank ("") in the innerhtml using javascript?
i have tried this.
document.getElementById("lab").innerHTML = document.getElementById("lab").innerHTML.replace(/*/g, '');
and i also tried doing the asterisk itself but it gets commented..
searched everywhere i can't seem to find ways to remove the appended in innerhtml aside from replacing it with a blank.. are there any other options?
i also tried searching for ways to use replace and other options. for added info i am using this for the validation of a form
thanks in advance!
You have to escape the asterisk:
.....replace(/\*/g, "")
because it is a special character in regular expressions.

Regular expression for check website url [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Regular expression for URL validation (in JavaScript)
How to validate url?
I have a textbox in a form where user can enter any website url. i want to check that url, whether it is valid or not through regular expression. it will accept only like this "http://www.google.com" or "www.google.co.in".
I have using a expression like
/((http|https|ftp):\/\/(www|WWW)|(www|WWW))\.[A-Za-z]{3}/ .
it is working but when i enter wwww.google.co.in, it says valid.
can any one help me please.
Do a request server side and check for 200 OK. Don't trust the client.
We needed it in our project a couple of weeks ago, and I think we used this one
function isUrl(s) {
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*#)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%#!\-\/]))?/
return regexp.test(s);
}
UPDATE:
I'm still working on it:
(ftp|http|https):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\/+#&#;`~=%!]*)(\.\w{2,})?)*\/?

Identify a URL Using Regular Expressions [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicates:
Checking for a valid url using Javascript Regular Expressions
PHP validation/regex for URL
I have a if statement that will check if the user entered a URL(HTTP Protocol only), like this:
if(/^regexp/.test(url))
But how should be this regular expression to check if the text is a URL or not?
I believe this little function might help:
function isURL(string){
regEx = /(\b(https?|ftp):\/\/[-A-Z0-9+&##\/%?=~_|!:,.;]*[-A-Z0-9+&##\/%=~_|])/gim;
return regEx.test(string));
}
Let us know if it worked out!
W.

Categories