How I would do this:
Copy// function you can use:
function getSecondPart(str) {
return str.split('-')[1];
}
// use the function:
alert(getSecondPart("sometext-20202"));
Answer from artlung on Stack OverflowUiPath Community
forum.uipath.com › help › studio
Insert string after specific character - Studio - UiPath Community Forum
April 18, 2023 - Hello. I’m trying to insert a string after this ‘&’ character. For instance, if I have ‘Books & Shelves’, I need to add ‘amp;’ after the & which should be like this ‘Books & Shelves’. I already tried this variablename.Insert(7, “amp;”), however, the name can always be ...
TutorialsPoint
tutorialspoint.com › how-to-get-a-part-of-string-after-a-specified-character-in-javascript
How to get a part of string after a specified character in JavaScript?
July 30, 2019 - To get a part of a string, string.substring() method is used in javascript. Using this method we can get any part of a string that is before or after a particular character.
W3Schools
w3schools.com › jsref › jsref_substring.asp
JavaScript String substring() Method
The substring() method extracts characters from start to end (exclusive).
Top answer 1 of 14
403
How I would do this:
Copy// function you can use:
function getSecondPart(str) {
return str.split('-')[1];
}
// use the function:
alert(getSecondPart("sometext-20202"));
2 of 14
216
A solution I prefer would be:
Copyconst str = 'sometext-20202';
const slug = str.split('-').pop();
Where slug would be your result
Futurestud.io
futurestud.io › tutorials › get-the-part-after-a-character-in-a-string-in-javascript-or-node-js
Get the Part After a Character in a String in JavaScript or Node.js
October 29, 2020 - string // delimiter is not part ...utorial-slug' The check if the given delimiter is empty is important. JavaScript splits a given string value at each character when using an empty string as the delimiter....
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › substring
String.prototype.substring() - JavaScript | MDN
The substring() method of String values returns the part of this string from the start index up to and excluding the end index, or to the end of the string if no end index is supplied.
Futurestud.io
futurestud.io › tutorials › get-the-part-after-first-occurrence-in-a-string-in-javascript-or-node-js
Get the Part After First Occurrence in a String in JavaScript or Node.js
February 10, 2022 - When interacting with string values you may want to retrieve a portion of the string after a given character sequence. This “after” method isn’t available in JavaScript directly and we’re building it ourselves. JavaScript comes with the String#split method allowing you to split a string ...
Ninox Community
forum.ninox.com › t › y4y82w1 › expression-to-extract-text-in-a-string-to-the-right-after-a-dash-character
Expression to extract text in a string to the right after a dash character - Get help | Ninox Community
March 21, 2024 - Rafael oops, the text 2 was my test yourtextfield and i forgot to rename it here in this example. So it should be replace(substr(YourTextField, index(YourTextField, "-") + 1), """", "")
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › substr
String.prototype.substr() - JavaScript | MDN
The substr() method of String values returns a portion of this string, starting at the specified index and extending for a given number of characters afterwards.
W3Schools
w3schools.com › jsref › jsref_substr.asp
JavaScript String substr() Method
The substr() method extracts a part of a string.
ReqBin
reqbin.com › code › javascript › i5foejaa › javascript-substring-example
How do I get a substring from a string in JavaScript?
January 29, 2023 - To get a substring from a string in JavaScript, you can use the built-in string.substring(start, end) method. The first parameter specifies the index of the first character from which to get the substring (in JavaScript, indexing starts from zero).
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Grammar_and_types
Grammar and types - JavaScript | MDN
It is considered best practice, however, to always write a semicolon after a statement, even when it is not strictly needed. This practice reduces the chances of bugs getting into the code. The source text of JavaScript script gets scanned from left to right, and is converted into a sequence of input elements which are tokens, control characters, line terminators, comments, or whitespace.
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › split
String.prototype.split() - JavaScript | MDN
Note: \d matches the character class for digits between 0 and 9. An object with a Symbol.split method can be used as a splitter with custom behavior. The following example splits a string using an internal state consisting of an incrementing number: ... const splitByNumber = { [Symbol.split](str) { let num = 1; let pos = 0; const result = []; while (pos < str.length) { const matchPos = str.indexOf(num, pos); if (matchPos === -1) { result.push(str.substring(pos)); break; } result.push(str.substring(pos, matchPos)); pos = matchPos + String(num).length; num++; } return result; }, }; const myString = "a1bc2c5d3e4f"; console.log(myString.split(splitByNumber)); // [ "a", "bc", "c5d", "e", "f" ]