I need How to split this string in javascript? [duplicate] - javascript

This question already has answers here:
Regular Expression to find a string included between two characters while EXCLUDING the delimiters
(13 answers)
Closed 5 years ago.
var faxNum = $("#txt_faxnum").val();
//Value : ""kekurt kekt809" <(732) 588-8300>"
I want to split between "< >". Example: Just I need to this section : (732) 588-8300
How to split this string ?

You can try this
var String=faxNum.substring(str.lastIndexOf("<")+1,faxNum.lastIndexOf(">"));

Related

JavaScript/regex: Remove text between brackets in string [duplicate]

This question already has answers here:
How to strip HTML tags from string in JavaScript? [duplicate]
(4 answers)
Closed 2 years ago.
How would I remove all <> tags from a string, and the contents within them?
<p>Hello, how are you doing <strong>today</strong></p>
to
Hello, how are you doing today
using JavaScript with Regex?
Here is how you can do it:
const input = '<p>Hello, how are you doing <strong>today</strong></p>';
const result = input.replace(/<[^>]+>/g, '');
console.log(result);

JavaScript RegExp concatinating variable [duplicate]

This question already has answers here:
How do you use a variable in a regular expression?
(27 answers)
Why this javascript regex doesn't work?
(1 answer)
Closed 4 years ago.
Trying to replace all a's in the string ignoring the case.
str = "All a's will be replaced";
str.replace(/a/gi, 'Aa');
As expected, the above line of code produces Aall Aa's will be replAaced
But,
regExp = new RegExp('/a/gi');
str.replace(regExp, 'Aa');
the above line with the use of RegExp pattern produces original string All a's will be replaced
How to achieve expected result?

match multiple occurrences, regex javascript [duplicate]

This question already has answers here:
Javascript - return string between square brackets
(6 answers)
Closed 4 years ago.
i want to find all occurrences of [anything-here] in sentence
I [am] John. [yesterday morning] я [русский] and Georgian [ქართული] and Indian [utf8-chars] and with symbols or space [good morning] or [hello, how are you?]
the result must be
[am]
[yesterday morning]
[русский]
[ქართული]
etc.
Thanks
var match = myString.match(/\[.+?\]/g);
Technically, this code will match all sentences between [ and ]

Javascript remove commas from string [duplicate]

This question already has answers here:
Remove characters from a string [duplicate]
(6 answers)
Closed 7 years ago.
I have the below variable in JavaScript. I want to remove the "comma" sign using jQuery /JavaScript.
var test = ",,2,4,,,3,,3,,,"
Expected output: var test = "2,4,3,3"
please advice
Use replace() with regex
var test = ",,2,4,,,3,,3,,,";
document.write(test.replace(/,+/g,',').replace(/^,|,$/g,''));
replace(/,+/g,',') - To remove multiple comma with one.
replace(/^,|,$/g,'') - To remove comma at starting and ending.

How can I remove a particular element from a string in javascript or check if it's there [duplicate]

This question already has answers here:
Remove characters from a string [duplicate]
(6 answers)
Closed 8 years ago.
I have a quick question
I have string var str="0-12345";
How can I actually remove the dash from the string if there is one in Javascript .. How can I check if a string has a dash , and if it has , remove the dash from it ?
you have forgot to do the homework before you asked here , any way
var str="0-12345";
var is_dashed=(str.indexOf("-") !== -1);
str= str.replace('-',''); //many more ideas , it seems simple to remove all '-'

Categories

Resources