Questions tagged [startswith]

Relates to the task of finding a subset of data at the beginning of a set of data. Usually refers to strings but could be other types of data. Please accompany with a language specific tag.

412 questions
5
votes
1 answer

How to return results where a field starts with a specific letter or letters in Elasticsearch?

I have some data like "last_name": "AA-WEST" "last_name": "VANDER AA" "last_name": "ARENDES-AA" And I'm trying to only get names that start with a, i.e. AA-WEST and ARENDES-AA I've tried "match": { "last_name": { "query": "a", …
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
5
votes
2 answers

jQuery Get Class That Starts With A String

The selector class can be: c-1 c-2 c-3 (etc...) The selector can also have other classes, so here is an example of a possible HTML:
I want to get the number after the c. In this case - I'll get 2. How can I do…
HTMHell
  • 5,761
  • 5
  • 37
  • 79
5
votes
2 answers

Lucens best way to do "starts-with" queries

I want to be able to do the following types of queries: The data to index consists of (let's say), music videos where only the title is interesting. I simply want to index these and then create queries for them such that, whatever word or words the…
Shivan Dragon
  • 15,004
  • 9
  • 62
  • 103
4
votes
1 answer

How to use tidyr pivot_longer when cols = any column that starts with a certain prefix

Each week, I get a raw dataset from which I need to produce a report. I would like to write one R script that will work every week. Unfortunately, the raw data has slightly different sets of columns each week depending on what specimens were…
Susie Derkins
  • 2,506
  • 2
  • 13
  • 21
4
votes
0 answers

Why does “abcd”.StartsWith("ـــــــــــــ") return true?

It was really strange for me. The following code returns true for every string. The character is Arabic Tatweel (U+640). "abcd".StartsWith("ـــــــــــــ") ;//returns true But when I change the StringComparer to StringComparison.Ordinal it returns…
Ehsan88
  • 3,569
  • 5
  • 29
  • 52
4
votes
1 answer

Local sequence cannot be used in LINQ to SQL implementation

I'm getting an error, see below, when I try to generate a list of the class MappedItem. In short the code example below tries to find products by category, date range and SKU. The requirement I have is that the user should be able to enter a comma…
Andy Evans
  • 6,997
  • 18
  • 72
  • 118
4
votes
2 answers

Create new pandas column based on start of text string from other column

I have a pandas dataframe with a text column. I'd like to create a new column in which values are conditional on the start of the text string from the text column. So if the 30 first characters of the text column: == 'xxx...xxx' then return value…
Pierre
  • 43
  • 1
  • 6
4
votes
6 answers

I need to write a regex in Ruby that returns true / false

I am trying to write a regex that takes a word and returns true for words starting with a vowel and returns false for words starting with a consonant. I have never written regex before, and I'm a little confused on how to write the expression. This…
alexnewby
  • 61
  • 4
  • 15
4
votes
2 answers

Python 3 Pandas Select Dataframe using Startswith + or

Looking for the correct syntax to do a str.startswith but I want more than one condition. The working code I have only returns offices that start with the letter "N": new_df = df[df['Office'].str.startswith("N", na=False)] Seeking a code that…
Arthur D. Howland
  • 4,363
  • 3
  • 21
  • 31
4
votes
2 answers

How to check if a key in a dictionary startswith the a key in another dictionary?

Here is a simplified scenario of what I am trying to do. I have two dictionaries: dictA = {"apple": 1, "orange": 2, "chocolate": 3, "mango": 4} dictB = {"man": "abc", "or": "asdf", "app": "fasdfkl"} How do I make it print (The actual order of the…
user3502285
  • 277
  • 5
  • 14
4
votes
5 answers

Extension of StartsWith that searches in all words

Is there an extension of string's StartsWith that it searches at the start of every word in the string? Something like: "Ben Stiller".StartsWithExtension("Sti") returning true I want this so I can make a predicate for searching. Lets say there's a…
sports
  • 7,851
  • 14
  • 72
  • 129
4
votes
3 answers

startsWith(String) method and arrays

I have to take a string and convert the string to piglatin. There are three rules to piglatin, one of them being: if the english word starts with a vowel return the english word + "yay" for the piglatin version. So i tried doing this honestly…
user1793532
  • 53
  • 1
  • 1
  • 4
3
votes
1 answer

How to find if a document starts with a given term in solr?

I have a solr index with indexed text. I'd like to query documents that start with a certain term. I didn't find a way to do that with the lucene or dismax query parser. Is there a way to do that? A solution I thought of is to index the strings with…
davidbrai
  • 1,229
  • 1
  • 9
  • 14
3
votes
3 answers

Get a list of rows starting from the same value as current row in pandas dataframe

I have a dataframe that I'd like to expand with a new column which would contain/match the list of all ids if they fully contain the row string_value id string_value 1 The quick brown fox 2 The quick brown fox jumps 3 The quick brown fox…
Nadiia
  • 217
  • 1
  • 7
3
votes
3 answers

Create a Column Based on Another Column Using grepl

Let's consider a df with two columns word and stem. I want to create a new column that checks whether the value in stem is entailed in word and whether it is preceded or succeeded by some more characters. The final result should look like this: WORD…
hyhno01
  • 177
  • 8