How do I specify a dynamic position for the start of substring?
you can use sub()
video_data_2$Video_full <- sub("^.*\\.","", video_data_2$Video_full)
In a dynamic string, how to start a substring at a certain character and end it at certain character?
After edits, you can simply do this for your requirements:
var string = "BLAH BLAH BLAH width: 673px; height: 123px; BLAH BLAH BLAH width: 1009px; height: 237px; BLAH BLAH";
var regExp = /(\b\w+:[^:]*px)/g
string = string.replace(regExp,'')
With regex, you can do like this:
var string = "BLAH BLAH BLAH width: 673px; height: 123px; BLAH BLAH BLAH width: 1009px; height: 237px; BLAH BLAH";
var regExp = /(\b\w+:[^:]*px)/g
var match = regExp.exec(string);
while(match != null)
{
var width = match[1]
match = regExp.exec(string);
var height = match[1]
match = regExp.exec(string);
}
After this, In each iteration, the variable width
will have the substring width: 4874px
and the variable height
will have the substring height: 898px
Extract substring in R from string with fixed start position and end point as a character found
You could try this:
a<-"http://www.imdb.com/title/tt2569314/companycredits"
sub("http://www.imdb.com/.+/(.+)/.+","\\1" ,a)
#[1] "tt2569314"
How to substring of a string with dynamically changing long text where indexes are unknown
You can use the indexof function to get the position of you starting subString :
text.substring(text.indexOf("As of 2016"), text.length);
Substring index with dynamic value and 1 column result
You can join the tables, group by code
an use GROUP_CONCAT()
to collect the tag values:
SELECT t.code,
GROUP_CONCAT(m.value ORDER BY m.id) tag_value
FROM tag t INNER JOIN master_tag m
ON FIND_IN_SET(m.id, t.tag_customer)
GROUP BY t.code;
See the demo.
Get specific part of dynamic string in TSQL
Assuming your items values can't contain ZZ
and ,ZZ
patterns (so they can be considered as real delimiters) you can do it using bunch of charindex
and substring
:
declare @src nvarchar(max), @Start_Position int, @End_Position int
select @src = 'AA=Item0,ZZ=Item1,ZZ=Item2,ZZ=Item3,ZZ=Item4,ZZ=Item5'
select @Start_Position = charindex('ZZ', @src, charindex('ZZ', @src) + 1) + 3
select @End_Position = charindex(',ZZ', @src, @Start_Position)
select substring(@src, @Start_Position, @End_Position - @Start_Position)
Explanation:
- Find occurence of first
ZZ
in the string:charindex('ZZ', @src)
- Find occurence of next
ZZ
starting from position of firstZZ
and add three characters - it will be position whereItem2
starts. - Find occurence of
,ZZ
characters starting from position determined in previous step - it will be bosition whereItem2
ends. - Do substring.
Insert string into string on a dynamic position
const text = "[GREEN][BLUE][RED]";
const inputNumber = 2;
const addingText = "[YELLOW]";
const index = text.split("[", inputNumber).join("[").length;
const output = [text.slice(0, index), addingText, text.slice(index)].join('');
console.log(output)
How to dynamically find the position of string in sql server?
To find a position of a substring in a string you can use CHARINDEX()
If you want to extract the number from your string you can do
SELECT SUBSTRING(s,
CHARINDEX('<#', s) + 2,
CHARINDEX('#/>', s) - CHARINDEX('<#', s) - 2) number
FROM
(
SELECT 'What is <#1#/>' s
) q
Here is SQLFiddle demo
Related Topics
How to Make Time Difference in Same Units When Subtracting Posixct
Different Breaks Per Facet in Ggplot2 Histogram
Ggplot2:Plot Mean with Geom_Bar
Standard Deviation in R Seems to Be Returning the Wrong Answer - am I Doing Something Wrong
Replace <Na> in a Factor Column
How to Retrieve Outlook Inbox Emails Using R Rdcomclient
Is There a Weighted.Median() Function
Converting a List of Data Frames into Individual Data Frames in R
Join R Data.Tables Where Key Values Are Not Exactly Equal--Combine Rows with Closest Times
Spearman Correlation by Group in R
Add a Box for the Na Values to the Ggplot Legend for a Continuous Map
Replace Logical Values (True/False) with Numeric (1/0)
Perform Multiple Paired T-Tests Based on Groups/Categories
Fixing Maps Library Data for Pacific Centred (0°-360° Longitude) Display
Ggplot2: Connecting Points in Polar Coordinates with a Straight Line 2
How to Add Multiple Captions in Ggplot2 Outside of the Main Graph Area
How to Stack Error Bars in a Stacked Bar Plot Using Geom_Errorbar