Linked Questions

129 votes
7 answers
249k views

How can I get the last character in a string? [duplicate]

If I have the following variable in javascript var myString = "Test3"; what is the fastest way to parse out the "3" from this string that works in all browsers (back to IE6)
leora's user avatar
  • 198k
2 votes
3 answers
16k views

How can I select the last 4 characters of a string using JavaScript? [duplicate]

This code chooses the highest numerical value between the data ids and adds an lime background to it. btw these numbers are hex values. my problem is that in hex values its the matter of the last 4 ...
Nur Bar's user avatar
  • 75
2 votes
3 answers
6k views

Get very last character of a URL [duplicate]

I have the following URL which I'm fetching: http://domain.com/search/?wpv_paged_preload_reach=1&wpv_view_count=1&wpv_post_id=205499&wpv_post_search=saint%20laurent&wpv_filter_submit&...
user2028856's user avatar
  • 3,175
0 votes
2 answers
7k views

Javascript: Getting last few characters of a string [duplicate]

This is a trivial problem if we are storing string in a variable. But out of curiosity, I need to understand how to achieve this without storing string in variable? // To get first few characters of ...
Aman Gupta's user avatar
  • 3,817
1 vote
3 answers
7k views

Get Last character of String in angular [duplicate]

Im trying to get the character after my string, I am using the bellow code but it dose not seem to work. Input value: fileinput-1 Expected result: 1 Any ideas. This is my code: str = element.id; ...
Beep's user avatar
  • 2,843
1 vote
1 answer
177 views

How do I get the n last letters in a string [duplicate]

I have a bunch of strings in javascript which hold dates such as "2015-02-17", how can I get the n last characters of that string as a substring like "02-17" or "17" ?
svarog's user avatar
  • 9,877
0 votes
1 answer
137 views

Javascript slice [duplicate]

I want to ask my ignorance about javascript I gave a little description, hopefully I can understand what I mean example: var a = `hello everyone` var b = a.slice (6) console.log (b) output = everyone ...
Rayyreall's user avatar
-2 votes
1 answer
96 views

I'm trying to write a function that gets a string from a field in html and return it if the first and the last characters are equal [duplicate]

I'm ought to do it without loops. with "if" and "else". The user writes a random word in the text field at the html and the function needs to check if the first and last letters are equals. If they ...
Ido Vidal's user avatar
804 votes
15 answers
950k views

How to get the last character of a string?

How to get the last character of the string: "linto.yahoo.com." The last character of this string is "." How can I find this?
Linto P D's user avatar
  • 9,205
6 votes
3 answers
11k views

substr() with negative value not working in IE

EDIT:I've changed the title, because the issue had nothing to do with IE image.load() firing - my substr() wasn't working (see accepted answer). There's a ton of posts about making sure that you ...
Tom Auger's user avatar
  • 20.2k
8 votes
5 answers
21k views

How to style a credit card expiration date input field to include spaces and forward slash?

I am wondering how I can style one input field (type = text) to display with spaces and a slash between numbers, like this: I know how to constrain the input to digits and perform validation. That's ...
Doug's user avatar
  • 5,336
4 votes
3 answers
17k views

In POSTMAN how do i get substring of response header item?

I am using postman to get response header value like below: var data = postman.getResponseHeader("Location") . //value is "http://aaa/bbb" for example I can print the value via console.log(data) ...
user1559625's user avatar
  • 2,693
3 votes
1 answer
4k views

Trying to get a session value from a post call in Postman: TypeError: postman.getResponseHeader is not a function

In Postman, I am trying to retrieve a session value returned from a post call and use it in another get call. I mean, I called via Postman: curl -X POST \ https://skyscanner-skyscanner-flight-...
Jim C's user avatar
  • 4,455
2 votes
3 answers
3k views

How to find string with last letter in angularjs?

I want to search a string using AngularJS by last character of the string. I have done search with first letter. I tried lastIndexOf() and endswith, but I can't get the result. This one is working ...
Elamparithi doodleblue 's user avatar
1 vote
4 answers
1k views

How do I split an array with multiple elements to get the last item in JavaScript?

I apologize if this question is too simple, I am just getting started in JavaScript. I have the following problem: A function is returning an array similar to: [ "Wed Feb 24 11:39:01 CST 2021&...
hungryhippos's user avatar

15 30 50 per page