Questions tagged [ends-with]

A common function to determinate whether the end of this string instance matches the specified string.

Determines whether the end of this string instance matches the specified string.

See also the documentation for .Net, Java or Python. There are also workaround for languages like JavaScript and c++.

133 questions
1144
votes
30 answers

endsWith in JavaScript

How can I check if a string ends with a particular character in JavaScript? Example: I have a string var str = "mystring#"; I want to know if that string is ending with #. How can I check it? Is there a endsWith() method in JavaScript? One…
Phani Kumar Bhamidipati
  • 13,183
  • 6
  • 24
  • 27
357
votes
22 answers

Find out if string ends with another string in C++

How can I find out if a string ends with another string in C++?
sofr
  • 5,407
  • 6
  • 28
  • 29
92
votes
6 answers

Does R have function startswith or endswith like python?

> startsWith('abc', 'a') [1] TRUE > startsWith('abc', 'c') [1] FALSE > endsWith('abc', 'a') [1] FALSE > endsWith('abc', 'c') [1] TRUE
user2165
  • 1,951
  • 3
  • 20
  • 39
61
votes
2 answers

Xpath "ends-with" does not work

I am trying to find an input element with dynamic id name always ending with "register". So far I tried this "//input[@id[ends-with(.,'register')]]" and this "//input[ends-with(@id,'register')]" none of these result in an element. What am I doing…
casper
  • 1,391
  • 2
  • 16
  • 29
55
votes
3 answers

How do I ignore case when using startsWith and endsWith in Java?

Here's my code: public static void rightSel(Scanner scanner,char t) { /*if (!stopping)*/System.out.print(": "); if (scanner.hasNextLine()) { String orInput = scanner.nextLine; if (orInput.equalsIgnoreCase("help") { …
Matao Gearsky
  • 555
  • 1
  • 4
  • 6
53
votes
3 answers

Python endswith() with multiple string

I have a string: myStr = "Chicago Blackhawks vs. New York Rangers" I also have a list: myList = ["Toronto Maple Leafs", "New York Rangers"] Using the endswith() method, I want to write an if statement that checks to see if the myString has ends…
user5455038
25
votes
6 answers

XPath testing that string ends with substring?

Given that the HTML contains:
How do we write the following expression in XPath: Find a
element whose tagname attribute ends with the…
Happy Bird
  • 1,012
  • 2
  • 11
  • 29
21
votes
4 answers

Powershell command to trim path if it ends with "\"

I need to trim path if it ends with \. C:\Ravi\ I need to change to C:\Ravi I have a case where path will not end with \ (Then it must skip). I tried with .EndsWith("\"), but it fails when I have \\ instead of \. Can this be done in PowerShell…
Ravichandra
  • 2,162
  • 4
  • 24
  • 36
19
votes
2 answers

How to check if String ends with something from a list. C#

I want to take a user's input, and check if the end of what they put in ends with something. But it's more than one string. I have it in a list. And I could check if the input ends with a string from the list one by one. However, I would just like…
Nathan Bel
  • 275
  • 2
  • 3
  • 6
17
votes
5 answers

How to determine if a string "ends with" another string in R?

I want to filter out the rows of a table which contain '*' in the string value of the column. Checking just that column. string_name = c("aaaaa", "bbbbb", "ccccc", "dddd*", "eee*eee") zz <- sapply(tx$variant_full_name, function(x) {substrRight(x,…
Malaya
  • 191
  • 1
  • 1
  • 7
13
votes
1 answer

AttributeError: 'NoneType' object has no attribute 'endswith'

I am currently working on a Python script that updates a web page. But running the main script generates this error:
mr.G
  • 167
  • 1
  • 1
  • 10
12
votes
3 answers

r dplyr ends_with multiple string matches

Can I use dplyr::select(ends_with) to select column names that fit any of multiple conditions. Considering my column names, I want to use ends with instead of contains or matches, because the strings I want to select are relevant at the end of the…
user42485
  • 751
  • 2
  • 9
  • 19
7
votes
3 answers

How to perform a case-insensitive search for files of a given suffix?

I'm looking for the equivalent of find $DIR -iname '*.mp3', and I don't want to do the kooky ['mp3', 'Mp3', MP3', etc] thing. But I can't figure out how to combine the re*.IGNORECASE stuff with the simple endswith() approach. My goal is to not miss…
MagicToaster
  • 117
  • 3
  • 8
5
votes
7 answers

how to check the string ends with space in javascript?

I want to validate if the string ends with space in JavaScript. Thanks in advance. var endSpace = / \s$/; var str = "hello world "; if (endSpace.test(str)) { window.console.error("ends with space"); return false; }
user3610534
  • 61
  • 1
  • 1
  • 2
4
votes
1 answer

How to test if string ends with a list of string

I have an array of string and another string, Is there a simple way to test if my single string ends with one of the strings in the array of strings? const strings = [ 'foo', 'bar', 'test' ]; if ('hi, this is a test'.endsWith(...strings)) {…
Ayfri
  • 570
  • 1
  • 4
  • 24
1
2 3
8 9