Questions tagged [substring]
Part of a string, or the function/method that returns part of a string
9,572
questions
0
votes
2
answers
73
views
Filter Pandas dataframe by columns that are a substring of a string
I am trying to filter a dataframe using the condition that string values in a column are a substring of a string outside of the dataframe. Example below:
df = [['a', 'b', 'c'], ['hello', 'bye', 'hello'...
-1
votes
1
answer
33
views
Get string between starting and ending between hash value example: #insidehash# will be insidehash
I have long string and I need to extract subsrting which will start and end with # in c sharp
For example: #insidehash#
Substring will be: insidehash
I am looking solution for the above problem
I have ...
0
votes
1
answer
53
views
Find the number of substrings of this string that start and end with different characters
Find the number of substrings of this string that start and end with different characters.
If the same substring appears multiple times in S, it is to be counted multiple times.
What approach should i ...
0
votes
1
answer
24
views
How to get the first letter after every hyphen and concat it to a new column in MySQL?
In Mysql DB, i've a column in which data are like in example. Now I need to get the first letter and the letters after the hyphen. There is no standard length of that string.
Example:
row1: asdaff-...
-3
votes
0
answers
33
views
Need Help coding this up, (full details in description and test cases) [closed]
public static String numRocks(String s, List<Interval> queries) {
StringBuilder result = new StringBuilder();
for (Interval query : queries) {
int left = query.getL()...
0
votes
1
answer
58
views
Retrieve text between two delimiters
I have text that is formatted in the following naming convention: ab123_text1_text2_text3_text4_text5_.xlsx. I am attempting to extract "**text4**" block. I have attempted to make use of the ...
0
votes
1
answer
30
views
TLE - Calculate the value sum of all 01? strings
I encountered this problem during a technical assessment last week.
Given a 01 string with some characters being "?". "?" means it can be "0" or "1". Now we ...
0
votes
2
answers
50
views
Find the weight of consecutive substrings
I encountered this problem during a technical assessment last week. I have no idea what I did wrong.
Given a list of integers of size n, find the number of consecutive substrings that have weights ...
-1
votes
2
answers
68
views
Check if a number is a digit in a number column SQL
I have a table with a column of DR. ID #'s. I want all the rows that have a 2 in them.
first_name
dr_id
joe
534
eric
267
allen
309
steven
125
gary
11
I have been searching for a number version ...
0
votes
2
answers
70
views
Recursive method to return substring enclosed in characters
I can't use other methods or add parameters and can only call the method recursively. I can't really understand how to approach this problem. I am struggling a bit wrapping my mind around recursion so ...
0
votes
1
answer
40
views
Can I get all substrings-1 char of a string with something more efficient than o(n^2)?
I want to get all the possible strings-1 character of a string. For examples for the string A13 I will get A1, A3 and 13. I made a function that has a quadratic time complexity and I want to know if ...
0
votes
0
answers
18
views
How can I update columns in Table X only when a subsection of a string column in Table X matches an entire string column in Table Y?
Framework & Goal
I am having trouble making the finishing touches on a project that involves updating null values for the columns street_address, city, state, zip_code, latitude, and longitude in ...
0
votes
1
answer
58
views
SQL Error: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS [closed]
Trying to update column of table from another table but need to modify the values using SUBSTRING. Statements work fine separately but error when combined.
Working
SET RoomName = DeviceName
Before:
...
0
votes
1
answer
31
views
PHP extract a substring between two strings before a substring found
I have this string of escaped html code:
$html="
...
euro�<strong>0,00</strong>�sono relativi a Operazioni finanziarie di <strong>Importo Ridotto</...
0
votes
2
answers
27
views
Select a substring in Oracle SQL after a specific word in the string in certain conditions only
Follow up from another users post entitled 'How do I Select a substring in Oracle SQL after a specific word in the string?'
I am using Oracle SQL Developer to run my script.
The solution works ...
0
votes
1
answer
42
views
String containing _ shorten to first and last character
I have file Text.txt containing:
sometext1 sometext2 sometext3 sometext4_sometext5_sometext6 sometext7 sometext8 sometext9_sometext10 sometext11
and i need only string containing _ shorten to first ...
1
vote
1
answer
44
views
What is the equivalent of str.Substring in PowerShell?
I'm making a simple compiling tool as a way to practice PS, and I need to extract a part of the string into another variable. For example:
[string]$Filepath = "C:/Users/xxx/Projects/file.cpp"...
0
votes
1
answer
56
views
Get data replacing text between braces()
I have a table where the location data can be in 3 different formats like mentioned below
United States (US);New York (NY)
United States (US);New York
United States;New York
I have to pull all the ...
0
votes
1
answer
27
views
Using VBA to lock 2x secondary sheets, while allowing Primary sheet to extract information while protected
I would like to use VBA to protect 2 secondary (Project)(Service) sheets using the same password,
but allowing the Primary (Comprehensive) sheet to extract information from those sheets while ...
0
votes
1
answer
37
views
Find objects in s3 based on a substring
I have a S3 bucket that contains objects in the following format
12345-abcde.json
56789-abcde.json
If I wanted to retrieve those objects from s3 based on abcde how could I do it?
I had a look at the ...
0
votes
1
answer
44
views
How can I isolate a particular word/words in a string using Python?
I have a dataframe where in one of the columns I only want to keep a subset of the string. In the example below I only want to keep the peoples names.
**Example: **
column 1
1.Joe Smith, NYC(212)
2....
-1
votes
0
answers
47
views
Having trouble to solve leetcode problem related to String
I'm trying to solve a leetcode problem. There are multiple solution to this in problem but all the solutions are using DP and Memoization. I'm trying to solve using StringBuilder but getting some ...
-1
votes
1
answer
35
views
How to Extract a Substring From a String from any character position
I am facing an issue while writing a query to extract a substring from a string available in my data extension.
I have a field with data in this format {"Body":"Hi TestSFMC"}. I ...
0
votes
2
answers
68
views
How to extract a portion of a URL in PostgreSQL
I'm trying to extract only a certain portion of a string URL field in my query. I am doing this in Amazon Redshift. The query is very simple, essentially
SELECT email_id, url
FROM emailsends
WHERE ...
0
votes
1
answer
23
views
How to sort files ascending from the name and extension en python?
Could you help me to solve this problem, please?
How could I to sort this .tif files ascending, in python?
data = ['prec0000.491.tif',
'prec0000.1.tif',
'prec0000.750.tif',
'prec0000.4.tif',
'...
0
votes
3
answers
56
views
Neo4j: Trying to find strings that follow a specific word or pattern in different blocks of data but can't figure out the right query to achieve that
I'm trying to find the values of a particular attribute contained inside the data of a particular type of node in our database. I think what I need in order to do that is to match for a certain string ...
-1
votes
2
answers
49
views
How to exclude substring with regex from a large list of strings more efficiently
I have a large list of strings (len > 1000000) which I'm trying to convert into a dataframe. Before that, I have to exclude some items which are numbers 20~22 digits long (e.g: ...
0
votes
3
answers
48
views
How to break up string based on specific length after finding the whitespace nearest to the character limit?
I have to break up a string field into multiple string fields if the original string exceeds a specific character limit. The original string can be of different lengths but the additional fields like ...
0
votes
2
answers
69
views
Checking for a substring in unicode value
Suppose I have a variable that has a unicode value in a Python script.
place_name = u'K\u016bla Mountain'
In this instance, 016b denotes that a macron accent mark is used over the u. I want to check ...
1
vote
1
answer
76
views
Why doesn't my code always detect palindromes in substrings correctly?
I am working with an algorithm that should find longest palindrome within a given string. So far, I've done some R & D and got a solution that's almost similar to mine. After doing some tweaks, ...
0
votes
1
answer
32
views
Most efficient way to extract data from string [closed]
There are so many ways to extract data from a string whether it be substring, split, etc. This is an open ended question and may be too open ended, but is there a "right" way to do this? For ...
-3
votes
1
answer
65
views
Get string between 3rd and 5th space [closed]
I am trying to extract the string between the 3rd and 5th space of a value. For instance, if the string is:
1588 Exeter Rd, Lebanon, CT 06249, United States
What I want to extract is:
Lebanon, CT
I'...
-4
votes
1
answer
51
views
Simplest way to parse a date time string like 20230202165638 in C#? [closed]
I wonder is there any simpler way to parse a concatenated date time value like 20230202165638 in C# other than using substring function ?
1
vote
1
answer
61
views
Swift substring range function doesn’t find match in specific cases
I am trying to find the range of substrings in a Tamil string. The range function particularly seems to have issues for substrings ending with the Unicode modifier glyph ‘Tamil pulli’ (U+0BCD).
The ...
0
votes
1
answer
24
views
No Matching Signature for Operator BETWEEN
Data describes Id, Activity Hour and StepTotal.
ActivityHour is defined in the format YY-MM-DD HH:MM:SS.
I am looking to obtain entries between 2016-04-12 AND 2016-05-12
where the time is between 08:...
-4
votes
2
answers
116
views
How to split a string into chunks based on specific length?
I have a following string
string input = "A123 B12345 777"
The expected result as an array as below,
A123 B12345 777
But the actual result is
A123 B12345
In the below code,...
0
votes
2
answers
33
views
Searching a dataframe to see if a substring exists in another dataframe using pandas
I'm having trouble to find a solution to this issue where I have 2 dataframes, df1 and df2.
df1
C1 C2
0 apple 5
1 grape 11
2 orange 7
3 cherry 9
df2
Item
0 apple soda
1 ...
0
votes
0
answers
15
views
Using substring function to parse text
Using this Substring function in a select statment returns error:
Substring([Requirements linked to HZD],1,CHARINDEX('-', [Requirements linked to HZD], 1))
error msg:
Invalid length parameter passed ...
-2
votes
5
answers
75
views
How to get the domain extension from a URL string?
How to find the type of website using the URL below.
.com – commercial website
.org – organization website
.lk – Sri Lankan website
Example: input > stackoverflow.com
Output > It's a ...
-1
votes
1
answer
42
views
Using CMD to batch remove substring from all files containing it
I have copied files from an old backup where all the files have been appended with a timestamp of the backup so a file that was previously called "background.jpg" has now been named "...
-1
votes
2
answers
44
views
Bring text before the second special character in SQL
I have a column that looks like this:
ss pullover jaq:rwbwht:40
ribbed cttn 5608:navy:10.5
shorts:black:xl
s:pigment wash mushroom:l
t tote bag:mushroom:1size
I need to extract the string before ...
0
votes
1
answer
55
views
Extract URL part of Text before a certain character
I am trying to extract the hostname from these strings, i.e. everything before the first % sign.
URL before the first % sign must be extracted (the bold parts), I have tried to use MID, SUBSTRING, ...
0
votes
1
answer
69
views
Computed Column on Split Value?
Using SQL Server 2022, attempt to create a computed column for indexing/queries on the 3rd part of a string separated by slashes (it's a URI).
ALTER TABLE MyTable
ADD SpotName AS (CAST((SELECT ...
0
votes
0
answers
49
views
Find and replace multiple substrings with the same pattern but keeping the different values between them in C#
Let me introduce my problem, I have an SVG image in string format and I would like to change programatically some properties. I think it will be easier to explain with an example:
This is my .svg ...
1
vote
3
answers
33
views
Extract specific string between under line in R
I have a string like this:
Euka_20220607_HD1_Swift_121_h3417.csv
Euka_20220608_HD32_Swift_5426_h87.csv
I want to remove Euka_ , HD[\d+] and suffix .csv and get:
20220607_Swift_121_h3417
...
0
votes
1
answer
17
views
substring function not recognized
I have some JS code to process the name of the HTML file and extract a substring as follows:
var pstr = "";
var xname = location.pathname.split("/").slice(-1);
pstr = xname....
2
votes
1
answer
21
views
Python_data categorization
I have dataset with columns "Product"- "Quantity" - "Price". The task is - to make new column "Product category", based on matching substring in the "...
0
votes
1
answer
27
views
Confirm String is a Substring (regardless of order)
I have a code trying to return True if a substring exist within a string
Example 1:
str1 = 'Wolverine vs Freddy Krueger'
str2 = 'Freddy Krueger Vs Wolverine'
str2.find(str1) # returns -1 (False)
...
0
votes
3
answers
33
views
Removing a File Extention from a String in Python (Reverse Indexing)
In a recent project I had to remove the '.txt' extention in a string. I tried using the .find() function as well as .index() and .search() in many ways but nothing came out of it. So, I wrote the ...
1
vote
1
answer
100
views
postman body get the last 3 characters on the username
{
"data": {
"username": "tell1535",
"password": "{{encryptedPassword}}",
"type": "session"
}
}
...