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
0
votes
3 answers

How to check for string.endsWith and ignore whitespace

I have this working function, to check if a string ends with a : var string = "This is the text:" function (string) { if (string.endsWith(':')) { // ends with : } if (string.endsWith(': ')) { // ends with : and a space } else { …
Filip Blaauw
  • 731
  • 2
  • 16
  • 29
0
votes
3 answers

Get string that matched with Any in LINQ

I needed to test a string to see whether it ends with any of an array of strings. I found the perfect solution using LINQ by following this answer: string test = "foo+"; string[] operators = { "+", "-", "*", "/" }; bool result = operators.Any(x =>…
dokgu
  • 4,957
  • 3
  • 39
  • 77
0
votes
2 answers

Writing results from os.walk and endswith to specific array location

I'm trying to search a series of folder/subfolders using filters, and then write the results out. It works if results are written to the same array, but can't figure out how to direct matches to specific arrays. Thanks for any suggestions. matchlist…
rNOde
  • 59
  • 5
0
votes
1 answer

Removing parts of a string with endsWith

my goal here to remove the word "like" if it appears at the end of the users input which gets replicated as a string. But I am struggling to see what the problem is with my work. When this is ran, anything before the word "like" is removed and I…
lg99
  • 71
  • 3
  • 11
0
votes
2 answers

Java: showInputDialog and ProcessBuilder

I just started coding in Java and i'm trying to make a program to run chkdsk when i click on a JButton. I will put a bit of the code here so you guys can help me: String disk = JOptionPane.showInputDialog(Janela, "Especifique a letra do disco…
0
votes
1 answer

LINQ Left Join with EndsWith instead of Equals

I am trying to do a LINQ query to entities using a left join that is not based on equality but instead using EndsWith. It is not working as intended and I am wondering if I am doing the comparison incorrectly. When I do the comparison as an…
0
votes
0 answers

Can't Use Starts/EndsWith with Scanner

Just wondering, is it not allowed to use Starts/EndsWith functions with Scanner? I'm trying to make a simple program where some elements from the set of array that I will provide will be printed out using those functions. But obviously there is an…
denmark16
  • 29
  • 7
0
votes
2 answers

Need endswith dot and one number

I need the conditional if my number inserted in an EditText ends with dot+any number. Example: 129.2 if ends with this, need that the new value like this. 192.20 thanks in advance.
Drewico
  • 47
  • 1
  • 10
0
votes
4 answers

Delete last character in string (Python)

I have a list filled with string objects. If the string object ends in a W, I want to delete/remove the W from the string. Also, in the only case that the string equals UW I do not want to remove the W. I have tried this: masterAbrevs =…
Philip McQuitty
  • 1,077
  • 9
  • 25
  • 36
0
votes
1 answer

Identify file extensions using endswith: not supported for file objects?

The program I am running needs to identify if an imported file is a gzipped. The files are coming in using argparse: parser.add_argument('file_sources', nargs='*', type=argparse.FileType('r'), default=sys.stdin, help='Accepts one or more fasta…
Thomas Matthew
  • 2,826
  • 4
  • 34
  • 58
0
votes
1 answer

sys.stdin file extension in Python 2.7

I'm trying to see if a file I input using sys.stdin has a .gz file extension. Usually I just use a file path directly but when I do sys.stdin it automatically opens it into an reading object. Is there any way to get the file name from stdin…
O.rka
  • 29,847
  • 68
  • 194
  • 309
0
votes
3 answers

Java: check if string contains more than one character

I would like to check my inputted string on a comma, which is pretty easy ( just used this: How can I check if a single character appears in a string?). Now I want to check if a character is present more than once. (in this case a comma (/u002C)) I…
bashoogzaad
  • 4,611
  • 8
  • 40
  • 65
0
votes
1 answer

Flex can not match ends-with symbol ($) when using yy_scan_string

I want to use the flex with string buffer, not the default stdin, so I'm using yy_scan_string. It almost works fine, except the "ends-with" pattern. e.g. %% ab$ {//do something} %% ab$ means matching "ab" if it is exact the ending string, using…
0
votes
1 answer

str.endswith() does not seem to consider the first if statment

I am using Python 3.3.2 on a windows 7 32bit machine. I am trying the following syntax: def make_from(inputString): if inputString.endswith('y'): fixed = inputString[:-1] + 'ies' if inputString.endswith(('o', 'ch', 's', 'sh', 'x',…
0
votes
4 answers

Storing Strings from a Text File into an array including different lines

at the moment I am trying to read in a text file of strings and put them into an array for each line. The text file has 10 lines and each line has a string of words (sentences extracted from a website). My aim is store these strings into arrays (an…
1 2 3
8
9