Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How to check (.) fullstop in var javascript using onchange ?
EG: var xxx = 120.00;
What function that can check (.) fullstop in this var
I use to use isnan but not work ,
If i use on Event onkeypress , I can use keyCode for check.
But i want to use even onchange, Can i do that ?
IndexOf will find the first instance of a given character
if (theElement.value.indexOf(".") !== -1) {
// Yes, it has a dot
}
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
The community is reviewing whether to reopen this question as of 12 months ago.
Improve this question
I am trying to write a regex to extract the items in the text below that start with the # and ends with )
const bodyOfText = "#[DataStructures](topic_DataStructures) is one #[Algorithms](topic_Algorithms) branch that could #[Make or Mar](topic_Make or Mar)";
So basically, will want an array that looks like:
["#[DataStructures](topic_DataStructures)", "#[Algorithms](topic_Algorithms)", "#[Make or Mar](topic_Make or Mar)"]
Using string match() we can try:
var bodyOfText = "#[DataStructures](topic_DataStructures) is one #[Algorithms](topic_Algorithms) branch that could #[Make or Mar](topic_Make or Mar)";
var matches = bodyOfText.match(/#\[.*?\]\(.*?\)/g);
console.log(matches);
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
With the following array of strings in javascript, is there a way to use the .filter to filter by the first word?
['Desk_One', 'Desk_Two', 'Desk_Three', 'Chair_One', 'Chair_Two']
For example to .filter(x = 'Desk_*')
['Desk_One', 'Desk_Two', 'Desk_Three']
Maybe this needs to be a regex
You can use startsWith() function like this:
let array = ['Desk_One', 'Desk_Two', 'Desk_Three', 'Chair_One', 'Chair_Two'];
let result = array.filter((item)=>item.startsWith(array[0].split('_')[0]));
console.log(result)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm trying to replace string
'null-null-1234' to '***-**-1234'
const p = 'null-null-1234';
const regex = /null/gi;
console.log(p.replace(regex, '***'));
Output => "***-***-1234" NOT AS EXPECTED
p.replace(/null-null/, '***-**')
I think what you actually want to do is to make a distinction between first and second values.
Hence, you probably need 2 regexes.
p.replace(/^null/, '***').replace(/-null-/, '-**-')
The first one will replace the null in first position (if any) by 3 stars, and the second replace will replace a null in the middle (if any) by 2 stars.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I need to check if the value of the input consists of numbers(0-9). Thanks for helping.
You can use Regular Expressions:
var result = /^[\d]+$/.test(yourInput);
Try to use isNumeric like this:
if($.isNumeric( input ) && parseInt(input)<10 && parseInt(input)>=0){
...
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
how would I check for string
<something> in var string = "some chars <something> somechars"
You can use String.match():
var res = string.match(/<something>/g); // ["<something>"]
If there is no match, the value of res will be null. See example on JSFiddle.