Newest 'substring' Questions - Stack Overflow

Questions tagged [substring]

Part of a string, or the function/method that returns part of a string

0
votes
4answers
43 views

Replacing parts of a string containing directory paths using Python

I have a large string with potentially many paths in it resembling this structure: dirA/dirB/a1ed4f3b-a046-4fbf-bb70-0774bd7bfcn and I need to replace everything before the a1ed4f3b-a046-4fbf-...
2
votes
1answer
37 views

Find using regex a substring exist , if yes segregate if from the main string in python

i have a string as below strng ="Fiscal Year Ended March 31, 2018 Total Year (in $000's)" if the above string has a year substring (e.g.. 2014,2015 etc), separate out the 'year' substring and the ...
0
votes
2answers
37 views

In DrRacket how do i alter my program that uses if statements to rather use a conditional statement

Here is the question I am trying to solve Write a function (last-substring-len s n). It consumes a Str and a Nat, and returns the substring of s with length n that comes last alphabetically....
1
vote
0answers
10 views

Selecting specific lines between characters of a text field formatted in HTML [duplicate]

I should preface this question by noting I have enough msyql experience to be potentially dangerous to a wet paper bag. I have a mysql table with a text field, Extra, that stores data in multiple rows ...
1
vote
2answers
62 views

An efficient way to find elements of a list that contain substrings from another list

list1 = ["happy new year", "game over", "a happy story", "hold on"] list2 = ["happy", "new", "hold"] Assume I have two string lists, I want to use a new list to store the matched pairs of those two ...
0
votes
1answer
24 views

Getting partial String in Swift5 [duplicate]

I am trying to extract a partial String from a given input String in Swift5. Like the letters 2 to 5 of a String. I was sure, something as simple as inputString[2...5]would be working, but I only got ...
0
votes
1answer
28 views

How to split a string in an array and make an associative array with it?

I have an array "arrayServers" with values. String[] arrayServers; and when I output data in a loop for (int i = 0; i < arrayServers.length; i++){ Log.i(LOG_TAG,arrayServers[i]); } I get ...
0
votes
4answers
79 views

MSSQL Replace string with another string after a certain character

I am receiving a email id into my sql procedure.I need to replace the email client with a defined string. Suppose I receive email id such as abc@gmail.com or pqr@yahoo.com or mnz@hotmail.com, in such ...
2
votes
1answer
46 views

Pandas substring using another column as the index

I'm trying to use one column containing the start index to subselect a string column. df = pd.DataFrame({'string': ['abcdef', 'bcdefg'], 'start_index': [3, 5]}) expected = pd.Series(['def', 'g']) I ...
2
votes
4answers
69 views

Get the second string of the URI with Perl regex

I need to get the second part of the URI, the possible URI are: /api/application/v1/method /web/application/v1/method I can get "application" using: ([^\/api]\w*) and ([^\/web]\w*) But I know is ...
0
votes
2answers
54 views

How i can divide the string with IP and ports?

I have such a line: 176.32.37.27:777754.38.156.202:777751.68.208.5:7777 How can the cycle inferred from this string of IP ports by using the split function or similar? To make it so: 176.32.37.27:...
0
votes
1answer
30 views

What's faster/should be rather used for short(ish) Strings: Split or Substring?

Swift 5, Xcode 10. I'm looping through an array of Strings (size probably < 20), each of them looks something like this: johnsmith.20190202102030.conf janedoe.19700101115959.conf I know the ...
-2
votes
1answer
28 views

What would be a regular expression in Python to find repeated characters in a string? [duplicate]

I am looking to find a regular expression or any other way on how to find any repeated substring of 10 bases or more consisting of dinucleotide repeats (e.g. ACACACACACAC, 5 AC repeats) in a DNA-...
1
vote
2answers
44 views

How to find index of selected text in getSelection() using javascript?

I am trying to apply style to the text selected by the user(mouse drag) for which I need to get the start and end index of the selected text. I have tried using "indexOf(...)" method. but it returns ...
1
vote
1answer
28 views

Filter a String which holds a TimeStamp - Kotlin

I have written a function which generate a TimeStamp and convert it to a String using toString(). I want to remove the whitespaces and other special character from that string. Is there is any ...
1
vote
0answers
54 views

Python: looking for a substring within a series

I'm trying to identify all the elements within a pandas Series (descriptions_list) that contains a the substring 'energy'. I've been trying to write a list comprehension in the following way: ...
1
vote
1answer
20 views

MongoDB : Remove last two characters from String

How to remove the last two characters of String in MongoDB? I have tried below solution but it did not work. $substr: [ "$document.field", 0, { $strLenCP: "$document.field" } - 2 ]
0
votes
0answers
13 views

I can't extract the “Band name” from a Goes-16 NetCDF file

Im trying to extract the "band name" from a NetCDF file, and is giving me a syntax error which I can't identify.The band name is identified by M3C13, and I only want to extract the 13 after the M3C. ...
1
vote
2answers
45 views

How to remove forward slashes from a vector in R?

I have a large character vector in R that looks, in part, like this: VRMMs = c("201905031740 METAR KDCA 031740Z AUTO ///11KT 10SM SCT041 24/18 A3000 RMK T02400180 MADISHF") I need to remove those ...
-4
votes
0answers
27 views

Spiting a string in two

Lets assume and input like : "This is a test" How could i split this string into a token1:"This" and a token2:"is a test" More specific. On a user imputed string (of unknown length) , how can i split ...
-3
votes
1answer
32 views

how to remove the last digit to the left of the cursor in EditText

I am was making a DEL button which would delete 1 char at a time. I recently added cursor movement to delete in between bud don't know how I used substrings for deleting normally. It would crash if ...
-1
votes
4answers
62 views

Count tandem repeats in Perl

I am trying to write a code that given this string: "TTGCATCCCTAAAGGGATCATCATCATCATCATCATCATCATCATCATCATCATCATCATCATCATCTTTGTGATCAA" finds consecutive repeats (alias tandem repeats) of substring ...
4
votes
7answers
139 views

How to substring this String

I want to get 4 parts of this string String string = "10 trillion 896 billion 45 million 56873"; The 4 parts I need are "10 trillion" "896 billion" "45 million" and "56873". What I did was to ...
0
votes
3answers
53 views

How to cut a string from the end in UIPATH

I have this string: "C:\Procesos\rrhh\CorteDocumentos\Cortados\10001662-1_20060301_29_1_20190301.pdf" and im trying to get this part : "20190301". The problem is the lenght is not always the same. It ...
0
votes
1answer
24 views

How to remove everything after the first space for each line in a file?

I have a file with a list of commands as follows: vi ../../www_com/pub/index.html vi www/pub/index.html vi yum.conf watch --interval=0.5 'ss -trnp' watch ll watch ls -la watch ls -lat watch ls -lat ...
2
votes
2answers
115 views

Delphi: strange substring result

Delphi Seattle (S10). Win32 project. Yesterday I got wrong result in my old routine. I found this line: sPre := Copy(aSQLText, p - 1, 1); aSQLText was 'CREATE', and p = 1. The sPre got "C" result. ...
1
vote
2answers
55 views

Remove substring from both ends of an std::string?

I'm trying to remove some start and end delimiters in a std::string. Is there a built in or better way to do this? Here is my current way: std::string sub = "~test.txt~"; std::string str = "~test....
0
votes
1answer
23 views

How to create a function in Python3 to return a substring from a string between two markers using regular expression?

I want to create a function in Python3, that will take 3 inputs: marker1, marker2, text and will return the substring between the 2 markers def findText(marker1, marker2, text): m = re.search(...
0
votes
1answer
19 views

My function incidentally remove numbers from string

my function accidentally removes numbers from my string by I want that they still remain. How can I change it? Original string that must be invariated; iPhone 7 plus 34 GB 10 inches echo implode(...
1
vote
2answers
52 views

issue with substring indexing

Instructions for this kata: In this Kata, we will check if a string contains consecutive letters as they appear in the English alphabet and if each letter occurs only once. It seems that my code is ...
-1
votes
5answers
49 views

Python: Is there a way to find and remove the first and last occurrence of a character in a string?

The problem: Given a string in which the letter h occurs at least twice. Remove from that string the first and the last occurrence of the letter h, as well as all the characters between them. How do ...
1
vote
1answer
51 views

How to find all occurrences of a subset of strings within another string and replace them with something else? (e.g: Emote replacement)

I am creating a chat feature for my app and we have a set of custom emojis. If the user types the shortcut for one of those emotes in their comment, we need to be able to detect the shortcuts in ...
-3
votes
2answers
48 views

Removing a string that starts with a substring

I want to remove all the words that contain a specific substring. Sentence = 'walking my dog https://github.com/' substring = 'http' # Remove all words that start with the substring #... result = '...
0
votes
3answers
54 views

I'm trying to understand how substring call is working in this code?

I know how substring works, but I was trying to understand how it works in the code below. The goal was to find the longest common prefix in an array of strings. The string input was {flower, flow, ...
0
votes
1answer
24 views

Substring Regular Expression for occurence

I want to select part of the string which occurs after the first underline _ and before the second, third or whatever amount of underlines _ occur in a string. For example I have strings such as: ...
-1
votes
1answer
15 views

Search for a criteria and get a sub-text

I have this text inside a cell from Excel: 1.Technical occurrence - Reason 1; (100%);04.02.2019 2.Systemic occurrence - Reason 2; (100%);06.02.2019 3.Technical escape - Reason 3; (100%);06.02.2019 4....
0
votes
4answers
70 views

How to extract a subString from android java String?

I tried to extract Sub-String from java string, but failed. i tried like this String text = "audios/{any_number} any_audio_name.mp3"; text= text.substring(text.indexOf('/'), text.indexOf('3')-2); ...
-1
votes
2answers
29 views

Get 2nd parent directory of given file

I have a script which finds files containing certain strings. Let's say my found file is: C:\temp\drivers\etc\file.INF I want to get the 2nd parent folder for that file. For example if it's: C:\...
0
votes
4answers
59 views

Remove character from dynamic string

I have a file with some junk values and i need to get rid of them while loading that file into a table. Giving here some example. File is semicolon separated, and last column has those junk values. ...
1
vote
3answers
68 views

Most elegant and fastest way to remove all leading zeroes in perl string

I wrote rmlz function for trimming all leading zeroes from string. # remove all leading zeroes from string use strict; use warnings; use feature 'say'; sub rmlz { my ( $str ) = @_; if ( $str =~ /...
1
vote
1answer
54 views

Why are my variable values being deleted?

I am trying to extract substrings in C. I have an input to my function of a string (char command[]) and am taking out parts of it. Upon debugging my code, I notice that values (condition and ...
-2
votes
2answers
50 views

How can i use substring in appropriate way?

When i try to print parts of string using substr() i got error titled by "out of range" , how can i fix this problem. #include <string> #include <iostream> using namespace std; int main()...
0
votes
1answer
43 views

Count number of occurencies of a given substring in a file, Kotlin

I have to write a function, which counts how many times does a substring occurs in the text and return a map (string - counts) I tried to make it, using .contains, but it doesn't count multiple ...
-1
votes
1answer
37 views

Count the number of words & lines that has multiple vowels in python

I am working on this coding problem "Count the number of words & lines that have more than X vowels for every Y words in every Z line" Basically the input string has multiple lines and I need to ...
-2
votes
1answer
40 views

How to find a Substring with a specific pattern?

Hi guys I cannot find how to take out a substring according to a specific pattern. This string is an Android Package name I see that there's a python library called re but I don't really understand ...
0
votes
2answers
62 views

Extracting a value from a key/value pair stored in a text field

I need to extract the value from a key/value pair stored in a text field using sql in oracle 11g. I can detect the "key" with SELECT * FROM mytable WHERE valuet2 LIKE '%' || chr(10) || '...
0
votes
1answer
22 views

How do I make the output to be “Avocado Roll, Salmon Temaki, California Roll, Miso Soup” etc.. I do not know how to use subtring method properl

Hi can you please help me with the substring method I do not know how to capitalise specific words only private static void viewAllItems(ArrayList<Item> itemList) { // TODO: P05 Task ...
0
votes
3answers
42 views

How to use substring() function to get middle string with relative index?

I want to extract characters from a string. However, the string doesn't have the same length every time. Basically I get data from a database and I want extract the value I need in it. But I'm stuck ...
0
votes
1answer
42 views

Using substring with multiple identical characters

I want to use substring in SQL server to capture a string between a specific text string and the following char(10). The problem is that there are several occurrences of char(10) in the complete ...
0
votes
1answer
32 views

C# Substring OutOfRangeException With Correct String Length

I encountered out of range exception during a substring operation. My string's length is 100, and the position of substrings are 58 and 94, which should not have given an out of range exception. ...