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
1
vote
2 answers

"Ends_with" function while reading an input file is not working

I am trying to create a C++ code that using boost libraries reads an input file like the following, 1 12 13 0 0 1 0 INLE . . . In this case, I must do an action if the condition…
heri-salmas
  • 103
  • 2
  • 12
1
vote
2 answers

How do I get the last character of a calculation in C?

I'm making an IF-statement where I want something to happen if the inserted number ends with a zero. The following doesn't work: #include #include int main() { int year; printf("Skriv in ditt födelseår\n"); …
1
vote
2 answers

Python (2.6.6) endswith() in for loop

park = "a park.shp" road = "the roads.shp" school = "a school.shp" train = "the train" bus = "the bus.shp" mall = "a mall" ferry = "the ferry" viaduct = "a viaduct" dataList = [park, road, school, train, bus, mall, ferry, viaduct] print…
1
vote
2 answers

Detect a File Extension in Java

I'm trying to detect if the file that I am opening is a HTML file. I have already tried this: try { String file = fileName.getCanonicalPath(); if (file.endsWith(".htm") | file.endsWith(".html")) { } } catch (IOException e) { …
user2228462
  • 589
  • 1
  • 5
  • 14
1
vote
8 answers

How to implement String.endsWith() without using built-in method .endsWith() in Java

I am trying to implement String.endsWith() method without the use of the built-in method String.endsWith(). Here is my code: public static boolean endsWithSuffix(String str, String suffix) { char[] chStr = str.toCharArray(); char[] chSuf =…
danksim
  • 617
  • 3
  • 9
  • 27
1
vote
1 answer

Compare two strings in java, how to print equals words

In java I got 2 strings (each contains a list of words for example ab,ac,ad,bb,bc,bd and second string which contains user input (for example word "a") I want to compare those 2 strings and get text that first string contain (like if startswith…
user2121038
  • 153
  • 1
  • 3
  • 14
0
votes
1 answer

how to change value of xml field based on condition with XSLT 2.0

I'm trying to change the value of an specific XML field using XSLT 2.0 if the value ends with "i". The change consists of adding a "0" (zero) before the value. XML field of interst would be '/message/object/struct/substruct2/ss2field2'. Change…
0
votes
1 answer

Using startsWith and endsWith works, but how to get middle characters?

My program take user input and compares it to words in a txt file. If it contains the user input such as "pre" in preload, it will print "prefix". If if contains "ful" like in helpful it will print "suffix". But there is also a result for infix, a…
Gauzl
  • 7
  • 2
0
votes
3 answers

How to extract some piece of word from a string?

I have the following string in python: datastring = """ Animals { idAnimal nameAnimal animalko5854hg[name="Jazz"] animal6ljkjh[name="Pinky"] animal595s422d1252g55[name="Steven"] …
asker
  • 298
  • 2
  • 8
0
votes
2 answers

How to use a method that takes an argument as the function in a map function, using a class.method notation?

I'm running the following code and cannot understand why python thinks that I'm not passing an argument to the endswith method: filtered_list = list(filter(str.endswith("mp4"), my_files)) This is the error that I'm getting: TypeError: endswith()…
Maria
  • 1
0
votes
1 answer

How to search multiple values in endswith Python?

Currently I'm making a bot with OpenAI GPT-3. I'm trying to see if the responses end with ".", "!", or "?" to stop generating responses. Here's my code: if a4.endswith(".", "!", "?"): if int(len(a + a2 + a3 + a4)) < 50: tc3 = a + a2 + a3 + a4 …
slyrp
  • 1
0
votes
1 answer

Python to get path of folder that endswith today's date

There are a lot of subdirectories in a directory. Every Subdirectory name ends with a date. I want to to open a subdirectory that ends with today's Date. Here is my code so far. But it is not Working. import datetime now =…
0
votes
0 answers

select(column, (contains()) not showing results

chase_2021 = chase[c(143:1020),] paychecks = chase_2021 %>% select(Posting.Date, Amount, Description, starts_with('CVS'), ends_with('PPD ID: 9953382345')) %>% filter(Amount > 100, Amount < 1000) I'm currently trying to find my…
alan503
  • 3
  • 2
0
votes
2 answers

Is there a more efficient way to check whether one line ends with another line in a large file

I have a file with 500,000 lines and I want to check for each line L whether any other line in the same file ends with L. I have already sorted the file by the length of the lines and have written the following code but it is to slow: def main(args:…
Leonid Glanz
  • 1,261
  • 2
  • 16
  • 36
0
votes
3 answers

Can ends-with() and text() be combined in XPath?

Already tried //*[ends-with(text()='updated the meeting')] and //*[ends-with(text(),'updated the meeting')] but did not work.
gg btn
  • 9
  • 2
1 2 3
8 9