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

Create a new column if ends with certain string

I have a data frame and a list. I want to check if strings in column ends with anything in my list. I want to create a new column showing if column ends with anything in the list then value is "Y", other wiese "N". my data frame Data looks like…
Bonjuga Lewis
  • 103
  • 1
  • 6
2
votes
2 answers

Is it possible to reduce function to one single line?

I wrote an image checker, now I wonder how can I reduce the number of lines in this function to (if possible) one single line. myFiles = ['image94.jpg','image95.png','image96.jpg','movie97.mov'] suff = ('.jpg', '.png') # Check if files are…
Roy Holzem
  • 860
  • 13
  • 25
2
votes
2 answers

AT command responses (understanding order of code execution on Arduino)

I'm sending AT commands to an ESP8266 from an Arduino Uno/Nano (ATmega328) and attempting to parse the end of the strings received in response to establish how the ESP reacted and whether it was successful (and whether it's ready to receive another…
AntInvent
  • 85
  • 6
2
votes
1 answer

TypeError: endswith first arg must be str or a tuple of str, not bool

I was trying to count the occurrences of words which end with several suffixes. I thought that endswith would accept an iterable; unfortunately, it did not. Below is the code snippet: s = 'like go goes likes liked liked liking likes like' lst =…
Mohammed
  • 1,364
  • 5
  • 16
  • 32
2
votes
2 answers

print item if it does not ends with a given pattern python

I have a list: mylist = ['summer_C','summer_C1','summer_P','summer_C123','summer_p32'] I want to print all items which do not end with the following pattern: '_C' or '_C%' (int) so it could be something like '_C' or '_C1' or '_C2939' My…
Boosted_d16
  • 13,340
  • 35
  • 98
  • 158
2
votes
2 answers

Regular Expression To Match String Not Starting With Or Ending With Spaces

I need a regular expression that makes sure a string does not start with or end with a space. I don't care if it has a space in the "middle" just not at the beginning or the end. I have a regular expression that almost works: ^\S.*\S$ Here are some…
Jan Tacci
  • 3,131
  • 16
  • 63
  • 83
2
votes
3 answers

String.endsWith() not working

I have the following string http://store.aqa.org.uk/qual/newgcse/pdf/AQA-4695-W-SP.PDF I want it so if the user forgets to input the http:// or the .PDF, the program will automatically correct this. Therefore, I tried this code if…
DreamsOfHummus
  • 735
  • 2
  • 7
  • 18
1
vote
4 answers

How can I replace text that starts or ends with a certain letter in Python?

sentence = "The quick brown fox jumps over the lazy dog." for word in sentence: if word.startswith("f" or "F"): uppercase_text = sentence.replace(word, str(word.upper())) print(uppercase_text) if word.endswith("e" or "E"): …
FJJ
  • 37
  • 4
1
vote
1 answer

Check if the String ends with a pattern from the List of Arrays - JavaScript

I have a array of Strings which are typically urls of the pages. I need to do certain action only on few of the pages (Applying Styles) So I have written the below code const location = useLocation(); const [margin, setMargin] = useState(); const…
Krish
  • 11
  • 1
1
vote
3 answers

How to select all columns where one column has rows that end with '006'

I'm using dplyr and I want to select all the columns on the table but return only the rows where one specific column ends with '006'. select(sample_id, ends_with("006"), everything()) The code above doesn't work. When I run it, it returns all rows…
Antonio
  • 417
  • 2
  • 8
1
vote
2 answers

How to Check All Array Element Inside endswith()

let array1 = ["?", "!", "."]; let array2 = ["live.", "ali!", "harp", "sharp%", "armstrong","yep?"]; console.log(array2.filter((x) => x.endsWith("?"))); The output is just: ['yep?'] Because the function endsWith() only checked for "?" as you see…
Royal ey
  • 15
  • 1
  • 2
1
vote
1 answer

Remove all values in a string before a backslash

I have this string AttendanceList XXXXXX US\abraham EU\sarah US\gerber when i try to use -replace it replaces all characters inserted in square bracket (including the first line AttendanceList) $attendance_new = $attendance -replace "[EU\\]", ""…
Tamarah
  • 19
  • 1
1
vote
1 answer

using endsWith(), question from R4DS learner

This is my first attempted reprex. I am working through R for Data Science. I am trying to narrow down a data frame to then be able to mutate it, but having trouble with the endsWith() function I think. When I run this section of the code I get the…
ksh530
  • 33
  • 4
1
vote
5 answers

check if last character of a string is a vowel in Javascript

I'm trying to make a beginner program that returns true if an inputted string ends with a vowel and false if not, but am having issues given endsWith() only allows to do one letter at a time. messing around with if else options today didn't help me…
AstralV
  • 119
  • 7
1
vote
2 answers

Python Script for startswith and endswith

So I made this script: names = open("names.txt","r") for loop in names: if loop.endswith('s'): print(loop) for loop in names: if loop.startswth('A'): print(loop) There was a file called names.txt which had 10 names in it. This program…
UdayanS
  • 47
  • 1
  • 8
1 2
3
8 9