FAQ Database Discussion Community


R - Conditional Substr from dataframe

r,data.frame,character,substring,substr
I need to substr from a column based on start and end locations. The start and end locations are derived from a character search. For example, a single column in Dataframe with 3 rows: 'Bond, Mr. :James' 'Woman, Mrs. :Wonder' 'Hood, Mr. :Robin' Expected Answer in Column 2 is: 'Mr.'...

How to get substring from a part of string while searching from the back

java,string,substring
I have a string with code from another JAVA class and i am extracting Doc comments. I have a string with the following content: "public static String[] scanread() throws Exception{" I need to get the "scanread()" how can i extract that? I was hoping something that looks for ")" and...

r substring wildcard search to find text

r,substring,wildcard
I have a data.frame column that has values such as below. I want to use each cell and create two columns- num1 and num2 such that num1=everything before "-" and num2=everything between "-" and "." I am thinking of using gregexpr function as shown here and write a for loop...

Regex: capturing groups within capture groups

regex,substring,match,capture-group
Intro (you can skip to What if... if you get bored with intros) This question is not directed to VBScript particularly (I just used it in this case): I want to find a solution for general regular expressions usage (editors included). This started when I wanted to create an adaptation...

How to return the full URL before the hash (using php)?

php,substring
The question basically covers it. I'm sure this question has been asked, but I can't seem to find it. Just to be clear, I have this url https://www.example.com/page.php#!/more-and-more/text/that-needs-to-go/away and I'd like to return with this url https://www.example.com/page.php I think I'm supposed to use substr but alas, I am here....

Using Charindex with in Substring is resulting in error

sql-server,substring,charindex
I have CHARINDEX function with in SUBSTRING which has to identify delimiter (|) value and return the value as parameter to a substring When delimiter is present it works fine select SUBSTRING('SH1684|32I5', 1, CHARINDEX('|', 'SH1684|32I5') -1) AS ID where the ID is SH1684 When it is not present This results...

Logstash - Substring from CSV column

csv,filter,elasticsearch,substring,logstash
I want to import many informations from a CSV file to Elastic Search. My issue is I don't how can I use a equivalent of substring to select information into a CSV column. In my case I have a field date (YYYYMMDD) and I want to have (YYYY-MM-DD). I use...

Generating Substring

c++,algorithm,substring
I am trying to generate all the sub string and store it in a dynamically allocated string array as shown: cin>>N; string str; cin>>str; ll m=N*(N+1)/2; string *sub = new string[m]; int k=0; for(int i=1,k=0; i<=N; i++,k++) { for(int j=0; j+i<=N; j++,k++) { sub[k]=str.substr(j,i); cout<<sub[k]<<' '; } } But the...

Cut substring after last slash?

javascript,regex,substring
How can i remove sub string (after last slash) from string in javascript like c:/Program File/Internet Explorer to c:/Program File/...

search a string in textbox from a source code file in c#

c#,string,visual-studio,search,substring
I'm a newbie to here. and i don't have any expirience in coding.I was stuck in coding part of my project.I have done it in C# in visual studio I wanted to search a string typed in text box in a file that is open as another string which is...

Confusion with Substring and Parse in SQL Server

sql,sql-server,sql-server-2008,substring
I am trying to parse a 14 character varchar (not always 14 characters, sometimes 12 or 10 or 0) column so that it displays the results in two parts by preceding a decimal on the second result. EmployeeCode ResultCol1 ResultCol2 ----------------------------------------------- 42135430620000 421354306200 .00 42135431750000 421354317500 .01 42135431740001 421354317400 .00...

How to prevent deleting the first character of edit text in Android

android,android-edittext,substring,android-textview
This is one of my Edit text in the application <EditText android:id="@+id/etFolder" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="/pictures" android:ems="10" > When it appear at first time it comes with "/pictures" User can change the text and enter another word. but how to prevent deleting "/" of Edit text. user can delete all other...

Get position of last character in a substring

php,string,substring,echo
$big = "new york city"; $small ="or"; $pos = strpos($big, $small); echo $pos; Returns 5 but I want it to return 6 which is the position of "r". Thanks in advance...

SQL Oracle | How would I select a substring where it begins with a certain letter and ends with a certain symbol?

sql,oracle,select,substring
If I had this: NAME EYES==ID==HAIR Jon Brown==F9182==Red May Blue==F10100==Brown Bill Hazel/Green==F123==Brown ...and I wanted to create a new ID column with the ID alone, and I know that everyone's ID starts with an 'F' and will end at the '=' how would I select a substring from the compact...

how to get substrings from a string in android?

android,regex,string,xpath,substring
Hello I have a long string and its having html tags like "" and "" and ,I want to get values from this strings,can anyone give me solution how to get values from it? my string is: <strong>1 king bed</strong><br /> <b>Entertainment</b> - Wired Internet access and cable channels <br...

Getting a sub string from a vector of strings

r,substring
I have a vector of strings ids <- c("NM_006690.2_PROBE1","333212.1_PROBE1","7602049CB1_PROBE1","NM_018065.1_PROBE1","1539036CB1_PROBE1","NM_021019.1_PROBE1","1440608CB1_PROBE1","NM_031270.1_PROBE1","613678CB1_PROBE1") A lot of discussing is already here: extract a substring in R according to a pattern. I want to remove everything after a dot(.) and want to remove all after _ before PROBE. i managed to remove . by read.table(text =...

concatenation of distinct substrings

java,string,out-of-memory,substring,concatenation
question - Arrange all the distinct substrings of a given string in lexicographical order and concatenate them. Print the Kth character of the concatenated string. It is assured that given value of K will be valid i.e. there will be a Kth character Input Format First line will contain a...

Making a java program that gives the number of distinct substrings of a input [closed]

java,substring
I need help making a program in java that will take an string input of letters (no spaces) and then output the number of distinct substrings. Example Output: *Input string to test: abc - “abc” has 7 distinct substrings. Input string to test: aaa - “aaa” has 4 distinct substrings.*...

SQL Server - Join Table1 to Table2 ON substring(T1.Field) = T2.ID

sql-server,text,substring,inner-join,patindex
I have two tables: MyOrders and MyDrivers. In table MyOrders, I have a column called Details (datatype TEXT - I know, but I didn't build the database...) In MyOrders.Details, there are sometimes comma-separated lists of numerical values which correspond to the ID values of table MyDrivers. The goal is to...

Shell Script get text between 2 special characters

string,shell,grep,substring
I have read a few things out there but can't seem to work out this particular problem. I am writing a shell script. I am reading a file to a variable using LOCAL_CONFIG=`cat local-config.php` Which has lines like this define( 'DB_USER', 'abcxyz' ); define( 'DB_PASSWORD', 'qwerty' ); How can I...

How to efficiently find a string between two given substrings?

java,string,substring
I have a string and I know two unique substrings and which one precedes which. What would be the most efficient way of finding the string in between? Right now I am doing this, which works well: middleString = line.split(firstSubstr)[1].split(secondSubstr)[0]; I need to do this for every single line in...

R Split dataframe by new line in column

regex,r,substring
I'm trying to split strings within a column by new-line "\n". Here is a dataframe sample_data: test_data <- data.frame(ID=c([email protected]', [email protected]'), Changes=c('3 max cost changes productxyz > pb100 > a : Max cost decreased from $0.98 to $0.83 productxyz > pb2 > a : Max cost decreased from $1.07 to $0.91...

extract substring in vb.net

vb.net,string,substring
I have following string, and would need to extract the X and Y values cut to a single digit after the point. A234X78.027Y141.864D1234.2 There are a few variables that can change here: the string can have any length and contain any number of values I know that X and Y...

How to split column value in Oracle sql

sql,string,oracle,select,substring
How to split a column value which is not having space or any other delimiter. I searched the forums but I couldn't able to find the solution for my scenario. Here is my scenario ID Column_Value 011 abcdefgh The result should be Column_Value1 Column_Value2 abcd efgh...

Impala Query: Combine multiple COUNT DISTINCT WHERE clauses

mysql,sql,count,substring,impala
On impala, I'm trying to count the number of distinct sample id's that contain "101", "102" or "103". Here is an example of my data: | sample_id | ___________ | 101-345-5 | | 101-345-6 | | 101-345-6 | | 102-345-5 | | 103-345-5 | | 103-345-8 | | 103-345-8 |...

Regular expression to pull out variable string

regex,string,python-2.7,substring
I have this list of strings in PYthon 2.7: list_a = ['temp_52_head sensor, uploaded by TS','crack in the left quadrant, uploaded by AB, Left in 2hr sunlight','FSL_pressure, uploaded by RS, no reported vacuum','art 9943_mercury, Uploaded by DY, accelerated, hurst potential too low','uploaded by KKP, Space 55','avogadro reading level, uploaded by...

substr function returning wrong result in php

php,vb.net,string,substring
I am a VB.NET developer working on a PHP project, I am trying to convert my VB.NET function into php, but not getting the desired result. After debugging I found a problem with substr function. in VB.NET I am using mid(105,2,1) This giving me output 0 but in php substr(105,2,1)...

How to avoid the StringIndexOutOfBoundsException if a substring is not in my original String?

java,string,substring,indexof
I have something like: String idCodice = cessionarioCommittente.substring( cessionarioCommittente.indexOf("<IdCodice>") + 10, cessionarioCommittente.indexOf("</IdCodice>")); used to extract the value inside the tag of an XML document represented by the content of the cessionarioCommittente String variable. The problem is that the <IdCodice> tag might not exist in the cessionarioCommittente String. So in this...

How to limit string length in a multidimensional array?

php,arrays,multidimensional-array,substring
I have a 2-dimensional PHP array containing strings ($fulltable) which I'm trying to fit into the datables grid (https://www.datatables.net/). Sometimes some of the strings are really long. I'd like to truncate each string to lets say to 75 charachters, which will make the fields more manageable on display. Is there...

substr() is not working as expected

php,date,substring
I am just trying to extract the date's year, month and day separately so that I can use it as per my wish. I stored the current date in $today and used substr() to extract the strings from it. But I am getting some strange behaviour from what I am...

Converting Right and Instr into vb.net Substring

vb.net,vba,substring
I wrote a code in VBA and I'm trying to transfer it to Vb.Net but I'm not sure of my job. VBA code (adapted to vb.net): Dim stringDate$ = "something happens: 03/12/2014 11:00" Dim C$ = Trim(Strings.Right(stringDate, Len(stringDate) - InStr(1, stringDate, ":", vbTextCompare))) Vb.Net code: Dim C$ = stringDate.substring(stringDate.length -...

Is there a group limit for Regep_replace in Oracle? (with regexp_replace issue)

regex,oracle,oracle11g,substring,reverse
At the moment I got a long input string that I want to reverse with regexp_replace. Normally I replace a strings position by using this (from within the begin clause in PL/SQL) variable:= regexp_replace(variable, '(.+) (.+) (.+) (.+)', '\4 \3 \2 \1'); In this case my variabele will be replaced...

How to find the string that contains substring of another string as a substring in php?

php,regex,string,substring
$a = "The quick brown fox jumps over a lazy dog."; $b = array("The lazy dog sleeps under the tree.", "...", ...); How can I find $b[0] that contains "lazy dog" in string $a? The problem is, I don't know beforehand that the searched substring is "lazy dog", something like...

If commas then get substring, else return whole string

mysql,sql,pdo,substring
How would I go about extracting a SUNSTRING IF a commas exists or just returning the whole string if no commas was found? For example: 640 => 640 310,321,450 => 310 1024,5,78, 900 => 1024 I was thinking of doing something like this: (suppose this string is in a table...

XQuery substring for a sequence of items

substring,max,xquery
I want to extract all values of a column from a table, determine the maximum of those values, and return that value. This is what I tried: let $abc := doc("file:///some_local_file")//AOSCAT_MetricDetail//table[@class="pretty-table"]//tr/td[13] return <li>{ fn:max(fn:substring($abc,1,1)) }</li> But fn:substring can't handle a sequence of more than one item. So I tried this:...

In Java, removing many character of a string

java,string,substring
In java, I want remove character of a string - this is my source code import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { // Let's challenge in my favorite language!! BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); Integer n...

Python3.x - counting occurences of all substrings using dictionaries

python-3.x,substring
Given some string S, this code will count the number of occurrences of all possible substrings of the string S. #count[i]=no of different substrings in the string that occurs exactly i times count=[0]*(100001) a=input() dic={} n=len(a) for i in range(n): temp="" for j in range(i,n,1): temp+=a[j] if temp in dic:...

Most efficient way to get a substring without exceeding the string length

java,substring
I am currently trying to turn a string into a digit using this code: public static int getDigit(String whole, int sub) { int d = Integer.parseInt(whole.substring(sub, sub+1)); print(Integer.toString(d)); return d; } But when I try to get the last digit I run into an error, I know the reason but...

Is there a better way to divide this string into substrings?

java,append,substring,indexof,lastindexof
I am trying to extract the "first_name" and "last_name" from a long string of information that look like this: { "123123123": { "id": "12321312****", "email": "***************", "first_name": "Marcus", "gender": "male", "last_name": "Bengtsson", "link": "https://www.facebook.com/app_scoped_user_id/123123123/", "locale": "en_EN", "middle_name": "Peter", "name": "Marcus Peter Bengtsson" } } The way I do it (which...

Regex to find all matches of from a string

python,regex,substring
I have the string: TEXT OF SWITZERLAND CASABLANCA, 2041 Cash 1234e I want to extract all alphanumeric values (digits compulsory) with length of at least 4, with or without the inclusion of the special characters /\_:.\-| Below is the Regex that I have tried. (?=.{4,}$)(?=.*[0-9])([a-zA-Z0-9/\\_:.\-|]+)$ But this only captures the...

Returning the string between the 5th and 6th Spaces in a String

substring,tableau
I have a column of strings that look like this: Target Host: dcmxxxxxxc032.erc.nam.fm.com Target Name: dxxxxxxgsc047.erc.nam.fm.com Filesystem /u01 has 4.98% available space - fallen below warning (20) or critical (5) threshold. The column name is [Description] The substring I would like returned is (dxxxxxxgsc047.erc.nam.fm.com) The only consistency in this data...

DFA construction in Knuth-Morris-Pratt algorithm

string,algorithm,substring,dfa,knuth-morris-pratt
I am referring to the outline of the Knuth-Morris-Pratt (KMP) algorithm for substring search in Sedgewick's book "Algorithms" (4th ed.). The KMP algorithm uses a backup in substring search based on a deterministic finite automaton (DFA). I understand how the DFA enters the algorithm, however I don't understand how to...

To get substring with pattern using Java

java,regex,substring
I have a file containing the records as bellow: drwxr-xr-x - root supergroup 0 2015-04-05 05:26 /user/root drwxr-xr-x - hadoop supergroup 0 2014-11-05 11:56 /user/root/input drwxr-xr-x - hadoop supergroup 0 2014-11-05 03:06 /user/root/input/foo drwxr-xr-x - hadoop supergroup 0 2015-04-28 03:06 /user/root/input/foo/bar drwxr-xr-x - hadoop supergroup 0 2013-11-06 15:54 /user/root/input/foo/bar/20120706 -rw-r--r--...

jquery substring based on many seperated characters

jquery,substring
Im looking for a easy and effective method of splitting a id string into many varaiables based on a seperating character. eg. var id = "12.34.red.blue.1253"; var sub1 = id.substr(0, id.indexOf('.')); //then what for the following substrings? Desired Result sub1 = 12 sub2 = 34 sub3 = red sub4 =...

Can anyone help me with why .substring() isn't working with setInterval roll out text?

javascript,html,substring,setinterval
the idea is to target a pre-defined invisible P element with text inside in the document and to make it roll out and visible again(the function that makes the text-invisible upon body load event isn't included). I've commented the line of code that doesn't work with the substring method on...

Why doesn't android like the \?

java,android,substring
I'm working in android studio 1.1.0 and I am trying to remove all of the \ and \n from a string but the IDE doesn't seem to recognize it as a string when I put it in "" it is blue instead of green like a normal string and it...

substring out of range

c#,string,substring
I am trying to extract the number out of the last part of the string, I have wrote a function to do this but am having problems with out of range index. Here is the string type="value" cat=".1.3.6.1.4.1.26928.1.1.1.2.1.2.1.1" descCat=".1.3.6.1.4.1.26928.1.1.1.2.1.2.1.3" and here is my function private static string ExtractDescOID(string property) {...

Substring from character to character in C#

c#,string,substring
How can I get sub-string from one specific character to another one? For example if I have this format: string someString = "1.7,2015-05-21T09:18:58;"; And I only want to get this part: 2015-05-21T09:18:58 How can I use Substring from , character to ; character?...

Creating regex to extract 4 digit number from string using java

java,regex,string,substring
Hi I am trying to build one regex to extract 4 digit number from given string using java. I tried it in following ways: String mydata = "get the 0025 data from string"; Pattern pattern = Pattern.compile("^[0-9]+$"); //Pattern pattern = Pattern.compile("^[0-90-90-90-9]+$"); //Pattern pattern = Pattern.compile("^[\\d]+$"); //Pattern pattern = Pattern.compile("^[\\d\\d\\d\\d]+$"); Matcher...

PHP - Substring processing [on hold]

php,substring
I have a set of strings that are in the format of This.is.An.Example.YYYY.More.Data.Here where YYYY is any valid year and I would like to get the string up until YYYY in the example so I would end up with a string that is This.is.an.Example.

Substring and gsub in R

r,substring,gsub
I have strings formatted like \t\tloc: 'Silver Spring, MD', that I extracted from a website and want to retrieve just the city name and state abbreviations, e.g. Silver Spring, MD. I was thinking about doing a combination of gsub and substr but the city name could change based on other...

Is the time complexity of this code O(N^2)

java,algorithm,performance,substring,time-complexity
This is a solution of mine for one of the problems in leetcode. Through my deductions, I concluded it to have an overall O(N^2) time complexity. However, I would like to get a confirmation on this just so that I don't continue making the same mistakes when it comes to...

How can I cut off characters from a specific column in a table?

javascript,jquery,angularjs,substring,slice
There are quite a few similar issues on here, but none of those solutions seem to work. I have a table where the content is dynamically loaded in via some voodoo, and I want to take the first 4 characters from the first <td> of each row off. The row...

Substring of a file

javascript,arrays,substring
I have a file that is structure like this : var file = "a|b|c|d, a|b|c|d, a|b|c|d, a|b|c|d, a|b|c|d"; Now I would extract all letters "c" and "d" of this file and put those letter in array, structure like this: var array = [ [a,b,1], [a,b,2], [a,b,3], [a,b,4], [a,b,5] ]; How...

How to find the longest substring with equal amount of characters efficiently

java,algorithm,substring
I have a string that consists of characters A,B,C and D and I am trying to calculate the length of the longest substring that has an equal amount of each one of these characters in any order. For example ABCDB would return 4, ABCC 0 and ADDBCCBA 8. My code...

Conditionally remove substrings in text with PHP [closed]

php,regex,substring
My scenario is I have a string containing raw html, for example: Remove this tag: <img src="path/to/image">. Also remove this tag: <img src="path/to/second/image">. But don't touch this <img src="cid:1259asdhasi">. What I need to do is find all img-tags within my string, check if their src begins with cid:, and if...

Recursively find a string within a string in C++

c++,string,recursion,substring
(C++) Given myString, I want to check if myString contains substring. Here's what I have so far, but it only returns true if the string begins with the substring. bool find(string myString, string substring) { if(mystring.length() < substring.length()) { return false; } if(mystring == substring) { return true; } for(int...

Error in printing all substrings of a string

c++,string,substring
This is in reference to the following answer by Synxis. http://codereview.stackexchange.com/questions/18684/find-all-substrings-interview-query-in-c/18715#18715 Suppose, I have to print all substrings of the string "cbaa". To do this, I have to invoke the method like this: findAllSubstrings2("cbaa"); If I take a string from user, and do the following: string s; cin>>s; findAllSubstrings2(s); it...

How can I trim the last two characters of each key in an array?

php,arrays,substring,associative-array
This is my array (input): $value = array("jan01" => "01", "feb02" => "02", "mar03" => "03", "apr04" => "04"); I am using this code to get the array keys: implode(" ", array_map("ucwords", array_keys($value))); Now my problem is I want to get all keys by triming the last two characters of...

Longest Non Repeating Substring in c++

c++,algorithm,substring
I am trying to find the longest substring with no repeated characters. I have a boolean vector to keep track of the 256 ascii characters. #include <iostream> #include <cstdio> #include <string> #include <algorithm> using namespace std; int main() { string s = "aaaaaaaaaaaaasadfrhtytbgrbrsvsrhvsg"; vector<bool> v(256, false); int j = 0,...

Java Add Numbers In String

java,arrays,string,sum,substring
I'm creating an application which will take an image as input and use tesseract and give an output. This image has numbers (can vary the numbers) I'm getting an output of, (when i run on the image) 0 1 12 1 0 I'm currently getting 5which is 0+1+1+2+1+0 cause im...

MS Access Substring

sql,ms-access,substring
I created a search Form for my db. It works great, if you enter everything in 100% the same as the db has it stored. What I want to change is the 100% part. If I enter "Jones" in the address tect box and hit search, I want "123 Jones",...

How to split dataframe column in R

r,grep,substring
I have a column in a dataframe called parm_value that I would like to split into two columns, lower and upper bound based on the position of the underscore in the field. I have been trying to use a combination of grep and substring with no success Current dataframe format:...

How to get the sub string from the start until the second last comma?

php,string,substring
From a string like this: $a = "Viale Giulio Cesare, 137, Roma, RM, Italia"; I need to get the string until tne penultimate comma: $b = "Viale Giulio Cesare, 137, Roma"; How can I remove everything finding the penultimate comma?...

Extract a substring in R

r,substring,gsub
> ldata2[2] [1] " \"pretty\": \"5:06 PM GMT on June 18, 2015\"," # Need to extract only the time information. In this case "5:06 PM GMT on June 18, 2015" # My attempt > time <- sub(".* :\"(.*)".*","\\1",ldata2[1]) This is the error message i get : Error: unexpected symbol in...

TERADATA - How to split a character column and keep the last token?

sql,substring,token,teradata,strtok
I have a table with article names and I would like to select the last word of each article of the table. Right now I'm doing it in SAS and I my code looks like: PROC SQL; CREATE TABLE last_word as SELECT scan(names,-1) as last_w FROM articles; QUIT; I am...

Changing Host Names dynamically [closed]

c#,substring
I have files on a local server with the address of \\localServerAddress\Folder\Program.exe. I need to remove the server address dynamically and replace it with a different server address that is being selected elsewhere in the form. The server names can be different lengths, therefore, I can not use the string.Substring...

SQL Issue using SUBSTRING and LEN

sql,sql-server,tsql,substring,special-characters
SELECT [Code], [Due Date Calculation], --original string that is causing the error --SUBSTRING([Due Date Calculation], 1, LEN([Due Date Calculation]) - 1) as OG, --here are the tests that run fine by themselves LEN([Due Date Calculation]) - 1 as Test1, SUBSTRING([Due Date Calculation], 1, 2) AS Test2, SUBSTRING([Due Date Calculation], 1,...

Exception in thread “AWT-EventQueue-0” java.lang.StringIndexOutOfBoundsException: String index out of range: 8

java,swing,substring,jcombobox,bufferedwriter
I have several jComboBoxes and jTextFields on my jPanel. Selected and typed values saving in text file. PrintWriter outfile = new PrintWriter(new BufferedWriter(new FileWriter... outfile.write(jcb1.getSelectedItem().toString().substring(1, 8)); outfile.write(jTextField1.getText()); But when I allow jComboBoxes to be empty, I cannot save empty value of jcb1 and getting this error: Exception in thread "AWT-EventQueue-0"...

SQL Query, Sort on Two Substrings

mysql,sorting,substring
I am looking to sort everything in a column based upon the 2nd number and then the 3rd number. For example: 1.197.980 is greater than 1.191.5061 The current SQL query that I currently have is the following. SELECT av_sig_ver ,CONVERT(SUBSTRING_INDEX(av_sig_ver,'.',-2),UNSIGNED INTEGER) AS 'av_sig_ver' FROM `test`.`test_fep_signatures` ORDER BY av_sig_ver DESC LIMIT...

How to add PHP strlen to custom field clauses

php,wordpress,substring
So I'm calling a value from a custom field using the standard: $key="mykey"; echo get_post_meta($post->ID, key/value, true); Id like to limit the characters that are displayed in the value. I'm not great with PHP, I can get my way around wp, but things like this stump me. This is what...

getting substrings from a string (i get the string from a text file)

java,android,string,substring
I'm trying to put my messages in a chat to make something look like this: This is my String of messages: String messages = "Me said: Hola\n"+ "Steven said: Hola android client\n"+ "Me said: como estas ?\n"+ "Steven said: Yo muy bien y tu?\n"+ "Me said: bueno si esto funciona...

Recursively get index of substring start in string in C++

c++,string,recursion,substring
Given the function: int getIndex(string mystring, string substring); How do I find the index of mystring where substring begins, if there is one? I don't want to use the default find function, I want to make my own (in C++). My find method return true if an occurrence of that...

Finding two different sub strings and printing everything between them in JAVA

java,arrays,substring,character-arrays
String theString="gtcaatgccaataaagt"; char[] charArray = theString.toCharArray(); int len=theString.length(); boolean start = false,end1 = false; for(int i=0;i<len;i++){ if(charArray[i]=='a' && charArray[i+1]=='t' && charArray[i+2]=='g'){ start=true; } if(charArray[i]=='t' && charArray[i+1]=='a' && charArray[i+2]=='a'){ end1=true; } } while(start==true && end1==true){ for(int i=0;i<len;i++){ System.out.println(charArray[i]); } } I want to print the characters between "atg" and "taa" from...

How to make a loop of variable of same name and get comma separated value in Java?

java,string,substring
I have a string of values which are comma separated i want to run a loop and assign first value of all three variable in a single String. For example in this scenario i want output as o1v1 o2v1 o3v1 o1v2 o2v2 o3v2 o1v3 o2v3 o3v3 Is there any possibility...

In Java, I have a String named string “A”( size 1). Why does string.substring(1) give no exceptions

java,string,exception,substring
In java, I have a String named string with the value "A". i.e. String string = "A"; Its size is 1 and we know that characters in a string are 0 indexed. They are represented as a Char array. Then, why does NOT string.substring(1); give me an exception?...

Extracting Substring from File Name

string,awk,substring,extract,cut
I have a list of files with the following file name format: [some unknown amount of characters][_d][yyyymmdd][some unknown amount of characters] I want to extract the substring that contains the date (yyyymmdd) which I know will always be proceeded by "_d". So basically I want to extract the first 8...

c# Substring doesn't find string

c#,substring
I have this paragraph inside my lotHtmlOriginal.Text waters71 </strong></p> <p><strong>websitesss.com/sblogin/login.shtml/</strong><br /> <strong>1234213:123123</strong><br /> <strong>213123:12312</strong><br /> <strong>4213:196028</strong><br /> <strong>32131:43423</strong><br /> <strong>4444444:96980507</strong></p> <p><strong>htt I issue is that when I make the second part of substring...

How to get an specific extract from a String?

java,string,substring
I want to get an extract from a String. The extract should contain the 2 words in front of the keyword and the 2 words behind the keyword. If the 2 words doesn't exist, the sentence should just end. Example: The word im looking for is "example". Existing Strings: String...

How to make a youtube link as embed?

java,jsp,substring
<% String song = request.getParameter("songname"); String band = request.getParameter("band"); String url = request.getParameter("url"); %> <div align="center"> <br><br> <% out.print(band + " - " + song); %><br><br> <iframe width="560" height="315" src="<%out.print(url);%>" frameborder="0" allowfullscreen></iframe> </div> <% %> Let's say url i get is like this https://www.youtube.com/watch?v=kXYiU_JCYtU i want to make it look...

Get a substring of a string

php,string,substring,substr,strpos
I've been trying to get a substring of a string that contains around 40 lines of text. The string is something like this but with aprox. 30 more lines: Username: example Password: pswd Code: 890382 Key: 9082 type: 1 Website: https://example.com/example Email: [email protected] I need to get the value of,...

Excel VBA Macro to get the substring of text before semicolon

excel,vba,excel-vba,split,substring
I have working code here. In section (3) it grabs values from a cell under a specific header and prints them to a masterfile. These values typically look like TL-18273982; 10MM TL-288762; 76DK CT-576 N/A I would like to grab just the information that is before the first semicolon. Not...

Creating windows of a sequence in r

r,substring
I have a character string for which I want to store all possible windows of a given size. In my first approach I have done the following to accomplish this: teststring<-c("ABCBDBDBCBABABD") n <- nchar(teststring) k <- 9 test = substring(teststring, 1:(n-k+1), k:n) test1 = strsplit(test,"") test2 = do.call(cbind, test1) But...

Removing specific sequences from a string

python,string,list,substring
I just started python and I have a quick question about strings. Say I have a string that contains both an open and closed bracket (with characters in it) that looks something like this: result = 10['1', '0']0 What I would like to know is how I can manipulate the...

Apply CSS Style Up to the First Period in Every Element with a Certain Class

javascript,jquery,jquery-selectors,substring
I'm trying to apply CSS styles to all of the characters up to the first period in the text of every element with a certain class. My initial attempt was to select the first 2 characters only, but that won't work if there are sub-items ( for example: "D (i)."...

PHP Regex to find a specific substring

php,regex,substring
So basically, I have a big string with some other information, and somewhere at the end, I have the following structure of a string: 62AC979D-5277D720 It is numbers and uppercase letters. I would like to extract this substring from many lines of the bigger strings which all contain it at...

How to remove the data from a string from particular character to particular character?

c#,asp.net,substring
How to remove the data from a string from particular character to particular character? I have a string data = "OK;;183.82.185.36;IN;India;Telangana;Hyderabad;500018;17.3753;78.4744;+05:30" I need India, Telangana and hyderabad in different string variables to store the IP address location string ipLocationurl = "http://api.ipinfodb.com/v3/ip-city/?key=0fb2d511503c450d077144d9a62194a12521db296995266977c6d4e&ip=183.82.185.36"; StreamReader stream = URLServerRequest(ipLocationurl); string response = stream.ReadToEnd(); ...

Python Extracting a substring of variable length

python,regex,substring,extract,slice
I'm trying to extra the name of a module from some verilog code. For example: module uart (inputs, outputs, etc) I know I can use pythons slicing to get a substring, but that only uses indexes. I need to make it so that it slices kind of like this: string[6:...

Cutting out and re-constructing string in javascript with substring

javascript,string,substring
I'm struggling with the logic...suppose I have this string: var s = '<span>foo bar</span><img src="www.foo.bar"><img src="www.blah.blah"> <span>blah blah blah</span>'; What I want to do is cut out the sources of each image and reconstruct the "s" string without the image sources. Here's what I have so far but it's wrong......

jQuery / Regex: How to compare string against several substrings

jquery,regex,string,substring,substr
I have a special validation need where I need to check if a string contains ANY out of several substrings like the following list: 12 23 34 45 56 67 78 89 90 01 I am new to jQuery and the only thing I could think of here is the...

Postgres : Select the maximum integer substring of a column value

sql,regex,string,postgresql,substring
I'm using postgresql and I'm having a trouble formulating the right sql query. The title of the question might sound weird, but it is exactly what I'm trying to achieve. I'm currently performing data curation with a particular table. If I have a table product containing : id | designation...

What is the equivalent of XML PATH and Stuff in Linq lambda expression (GROUP_CONCAT)?

sql,linq,lambda,substring,for-xml-path
I am having a table like this : EmployeeId EmployeeName ItemName 4 Ganesh Key Board 4 Ganesh Processor 1 Jignesh Key Board 1 Jignesh Mouse 1 Jignesh Processor 3 Rakesh Key Board 2 Tejas Key Board 2 Tejas Mouse 2 Tejas Processor I need to query this as if the...

Selecting Substring SQL

sql,sql-server,select,substring
I need to select a substring that is found between (). The starting and ending position will vary, as well as the length of the substring. I have had moderate success with the following but not 100%. It will work for some values but not for others, it return blanks...

Best way to get substrings of a longer string

c#,string,substring
What's the best way in c# to extract subtrings of a longer string like: String str = "Car: volvo Wheels: 4 doors: 5"; Lets say I want the values volvo, 4, 5 inserted into string car string wheels string doors string newStr = str.Substring(read.IndexOf(':'), read.IndexOf(" ")); then after I have...

How to insert sub string of a mysql column into empty columns within loop using php?

php,mysql,substring
I have a phpMyadmin database table with last three varchar rows: Location, lat, long 'Location' has latitude and longitude numbers that I separated using sub string and assigned to variables. I am trying to insert these variable into last two row in the table named: 'lat' and 'long. This is...

Type mismatch in expression 'System.Data.UnaryNode'

c#,datatable,substring,unary-operator,datacolumn
I have a data table with a column (strDate) that contains values like '20150519'. I want to create a new DateTime column in the data table (without using a loop) that contains the date representation of strDate. I tried this: table.Columns.Add("NewDate", typeof(DateTime)).Expression = "CONVERT((SUBSTRING(strDate, 0, 5) + '/' + SUBSTRING(strDate,...

Substring a stringRaw from String1 to String2

vb.net,visual-studio,substring,visual-studio-2015
If you didn't really get it what I actually want let me explain you better: I have a: stringRaw = "<img src=\"http://www.b92.net/news/pics/2015/01/15/111348233854b817af5b4bc991063053_v4 big.jpg\" title=\"\" alt=\"\" />" Now I have to do some kind of substring from string1 = "<img src=\"" to string2 = "\" title=\"\" alt=\"\" />" and have to...

Dealing with FileReader and subString

java,substring,filereader
I'm trying to read a file .txt which contains 8 lines of Stores in different regions. Each line has 15 characters. When I run this code, just the first line is printed and afterwards it throws this: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 10 at java.lang.String.substring(String.java:1951)...

How get a whole word with just a part of it?

java,string,substring
Example: I have a String like this: String query = "....COD_OP = 1 AND USER_DATA_SIGNIN = ...." I need to get the whole word ("USER_DATA_SIGNIN") when it have the "_DATA_" part. In java is possible use some kind of substring inversely ? In this case I don't know how to...

How to post password from iOS app to PHP server securely?

php,ios,objective-c,substring
I know almost nothing about internet security, and I came across this question. The situation is: The user has to login to PHP based server from iOS app. I did POST sending to php from xcode something like this: NSString *parameter = [NSString stringWithFormat:@"userid=%@&password=%@",usernameVar, passwordVar]; NSData *parameterData = [parameter dataUsingEncoding:NSASCIIStringEncoding...