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
4
votes
5 answers

Delete end of element from a list if the element ends with an element from another list

I have the following two lists. If my_list ends with an extension from extensions, then it should be removed. I can't seem to find a solution that doesn't require too many lines of code. Input: my_list = ['abc_sum_def_sum', 'abc_sum_def_mean',…
m_h
  • 485
  • 5
  • 11
4
votes
2 answers

JSTL Bug in function endsWith?

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> ${fn:endsWith(some, 'ef')} returns true ${fn:endsWith(some, 'ef')} returns false It looks like the…
LancerX
  • 1,211
  • 7
  • 23
  • 40
3
votes
1 answer

R equivalent of endsWith to check against a list of strings

I am attempting to check whether values in a column of a data frame end with any value from a predefined list of strings contained in a vector. I understand it is possible to check against a single string using endsWith, but I have not found a way…
hawkaterrier
  • 368
  • 3
  • 15
3
votes
3 answers

How to return which element from the tuple matched in the endswith function

I am trying to make a file renamer using Python. I was able to successfully scrape Wikipedia for list of episodes, but while making the renamer file I was met with a lot of discrepancies. What I want is that instead of '.mkv' at the end I want to…
Ayush Mandowara
  • 490
  • 5
  • 18
3
votes
4 answers

How can I sort given a specific order that I provide

I am trying to sort files in a directory given their extension, but provided an order that I give first. Let's say I want the extension order to be ext_list = [ .bb, .cc , .dd , aa ] The only way that I can think of would be to go through every…
uniXVanXcel
  • 807
  • 1
  • 10
  • 25
3
votes
2 answers

Python 3.4 endswith()

I'm not exactly a Python 3.x pro but I was finding stuff to do on Python 3.x and I found this: The third person singular verb form in English is distinguished by the suffix -s, which is added to the stem of the infinitive form: run -> runs. A simple…
user5428930
3
votes
7 answers

Search array of filenames for file ending with ".txt"

I have an array with filenames. I want to check if the array have a file with extension '.txt'. How can I do that? in_array only checks for a specific value.
trogne
  • 3,402
  • 3
  • 33
  • 50
2
votes
2 answers

How to access a tag in xml that ends with specific text using ends-with

I have an example xml
/14 S22 10000 1
Perl_Newbie
  • 101
  • 6
2
votes
3 answers

C# EndsWith sometimes gives false results

"Cs".EndsWith("s") and "cs".EndsWith("s") gives me "false". I put together a simple console application to present the problem: string[] strings = { "s", "As", "Bs", "Cs", "Ds", "Es", "as", "bs", "cs", "ds", "es", "AAs", "ABs", "ACs", "ADs", "AEs"…
2
votes
2 answers

.endswith() method raises exception "AttributeError: 'str' object has no attribute 'value'"

I'm trying to use the library discord.py to create a "faction bot". The create command of my bot raises the exception AttributeError: 'str' object has no attribute 'value'. Here is my code: @commands.command() async def c(self, ctx, color: str, *,…
IAmAHuman
  • 199
  • 6
  • 16
2
votes
7 answers

How to extract a list of names that start with an ‘s’ and end with a ‘p’ in input_list using filter() function in PYTHON?

input_list = ['soap','sharp','shy','silent','ship','summer','sheep'] Extract a list of names that start with an s and end with a p (both 's' and 'p' are lowercase) in input_list using filter function. Output should be: ['soap', 'sharp', 'ship',…
Ali Bawazeer
  • 29
  • 1
  • 2
2
votes
3 answers

Is there a way to dplyr (tidyverse) map my dataset, find columns ending with the same suffix then keep just one?

Let's say I have two different measurement tools (a3 and a4) developed to assess psychological attributes, such as communication skills. a3 tool is the first version of the instrument and it has 6 items (1,2,3,4,5,6). A4 is the updated version of a3…
Luis
  • 1,388
  • 10
  • 30
2
votes
2 answers

How to check if last character of a string is a digit/number by the fastest way in plain JavaScript?

How to check if last character of a string is a digit/number in plain JavaScript? function endsWithNumber(str){ return str.endsWith(); // HOW TO CHECK IF STRING ENDS WITH DIGIT/NUMBER ??? } var str_1 = 'Pocahontas'; var str_2 = 'R2D2'; if…
RE666
  • 91
  • 1
  • 9
2
votes
1 answer

How can I do variable.endswith("a" or "b" or "c"....) : doAThing in Python?

I'm working on a small piece of translation software in its early stages. I'm trying to take the end character of a word and do something with it, but I need to differentiate between different cases. How can I use if endswith("a" or "b" or "c") :…
jaw12346
  • 65
  • 4
2
votes
3 answers

How to print portion of the string from 'startswith' till 'endswith'

I like to save portions of the original text file, which can be identified in between 'startswith' and 'endswith' strings, into a new text file. Example: The input text file contains following lines: ...abc… ...starts with…
anatta
  • 163
  • 1
  • 3
  • 9
1
2
3
8 9