How to include Micro symbol (µ) in Javascript regex? [closed] - javascript

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I need to use the following regex in my Javascript code:
/\D*(\d+)\s*([TGMkmµnp]).*/g
However, the µ symbol is causing syntax error.
How can I fix this?
The error message is:
At "value = str.replace(/(+)(TGMk"
error110: SYNTAX ERROR while lexing character "µ".
I am using TestComplete software.
My code is as simple as this:
function GetVoltageDbl(str)
{
var value = str.replace(/\D*(\d+)\s*([TGMkµmnp]).*/g, "$1");
var prefix = str.replace(/\D*(\d+)\s*([TGMkµmnp]).*/g, "$2");
Log.Message(value);
Log.Message(prefix);
}

Try replacing µ with \u03BC as follows:
/\D*(\d+)\s*([TGMkm\u03BCnp]).*/g

Please try this \µ . It's need to help

Related

Syntax Error jQuery [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
there is a syntax I can't figure out.
$(this).append(free);
And here is the error message in the console:
Uncaught SyntaxError: Unexpected token <
I have no idea, what this error message wants to tell me, because it makes no sense to me.
Simple, you are missing quotes:
$(this).append('free');
From the docs the parameter you pass can be:
"DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements."
$(this).append('free');

Retuning a string in PHP [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I wanted to return following string, but I still couldn't get it done right for couple of hours. CAn anyone tell me what did I do wrong? Thank you.
<?php
return 'rs...#gmail.com.com';
?>
You have single quotes in the JavaScript code in your onclick attribute. You need to escape these by placing a backslash before each single quote.

I cant convert number to string? (even when following what I've done before) [JavaScript] [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I've heard a lot that the best way to learn to program is to experiment and test a bit. So I recently learned about loops and while loops etc. and decided to try and make a program that would just count from 0-100. I did this very easily, and everything works fine. The only thing not working is that fact that I can't get the value of count (ie 0,10,20, etc) to work in the console.log? Thanks so much.
for(var count=0; count<=100; count+=10)
{
console.log("thrusters at "+count" percent!");
};
You're missing a second +
for(var count=0; count<=100; count+=10)
{
console.log("thrusters at " + count + " percent!");
};

Unexpected Token Error with jQuery "{" [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am getting an unexpected token error when in my console when I run the page. Can anyone help point out where this is coming from? I believe I'm going blind because I can't see it.
define('QuoteSetupPageController', 'jquery' {
this.init = function() {
$(document).click(function(){
$('.header-message-indicator').hide();
});
}
});
Error is on line 1.
Thank you.
It should be:
define('QuoteSetupPageController', 'jquery', {
You were missing a comma.

Javascript .charAt(0) gives unexpected results [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
var category = "a()";
if(category.charAt(0) == /^[a-zA-Z]+$/){
/*This part doesn't gets executed*/
/*What is the problem with the if condition?*/
}
You are comparing your character with an instance of a regular expression.
You actually want to test your character with the regular expression.
You can do that like this:
var category = "a()";
if (/^[a-zA-Z]+$/.test(category.charAt(0))) {
// Now it will get executed
}
Further reading on JavaScript regex flavor:
http://www.regular-expressions.info/javascript.html

Categories

Resources