w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Turn comma-separated string into GetFiles SearchPattern
string newStr = string.Join(",", supportedImageFormats.Split(',') .Select(r => "*." + r)); Output: Console.WriteLine(newStr); *.jpg,*.pdf,*.doc,*.docx,*.xlsx

Categories : C#

Remove first N fields separated by delimiter
assume your cursor at the first line, first column. also the fields have same width (as your example shows) You could press the below key sequence (6 keystrokes ): <Ctrl-V>G3f,x If the fields have different length, you could: record macro with q : qq0v3f,xjq then, replay the macro, for example, 99 times: 99@q or do it in command line: %s/v^([^,]*,){3}//

Categories : Regex

Counting delimiter in String and splitting the other character between the delimiter in SQL Server using loop
I think this will do the job. while @index1 < LEN(@symbol) begin set @index2 = CHARINDEX(',',@symbol,@index1) set @op = substring(@symbol,@index1,@index2-@index1) print @op set @index1 = @index2+1 end

Categories : Sql Server

Search a database for a sentence separated by a delimiter in SQL
If you have an application layer that in-turn interacts with the database, then you should generate that portion of the query, searching for each word at the beginning, in the middle and at the end of the sentence column of each record, for each word in the search text. ( sentence LIKE 'token;%' OR sentence like '%;token;%' OR sentence like '%;token' ) E.g. Search text = "search google"; Query: ( sentence LIKE 'search;%' OR sentence like '%;search;%' OR sentence like '%;search' ) AND ( sentence LIKE 'google;%' OR sentence like '%;google;%' OR sentence like '%;google' )

Categories : SQL

Implementing a split string by delimiter function in C
*array = (char *)malloc(sizeof(char) * (j + 1)); should be array = (char *)malloc(sizeof(char) * (j + 1)); // malloc returns a pointer, no need to dereference here and then this while(*(string++) != delimiter) *(*array++) = *(string++); should be while(*(string++) != delimiter) *array++ = *(string++); // dereferenceing once would do and finally this **array = ''; should be *array = ''; // same as above The reason for all the above changes are the same. array is a pointer and not a pointer to a pointer. Additionally, in your code, the loop index i has never been initialized and hence is bound to lead to non-deterministic behaviour. Either initialize it in declaration like int length, count, i = 0, j = 0; or in the loop initialization like for

Categories : C

Class design / pattern for a chain of objects separated by a variable delimiter
Here comes a proposal of how to face your problem: Public Class ExpressionFromChainOfExpressions Inherits Expression Private ExprChain As List(Of Expression) Private ExprConn As List(Of Connector) Public Enum Connector AndConn OrConn End Enum Public Sub AddExpression(Expr As Expression) 'Might have to be changed to account for connectors If ExprChain Is Nothing Then ExprChain = New List(Of Expression) ExprChain.Add(Expr) End Sub Public Overrides Function ToString() As String Dim outStr As String = "(" For i = 0 To ExprChain.Count - 1 outStr &= ExprChain(i).ToString() If i < ExprChain.Count - 1 Then outStr &= 'will account for the given connector (as stored in

Categories : Vb.Net

Is there a way to turn off result sets for stored procs?
This way of populating doesn't output result. select sq into @sq from a_nice_table where id = @a_nice_var limit 1; It works for multiple variables, too select sq, whatever, one_more into @sq, @v_whatever, @v_one_more from a_nice_table where id = @a_nice_var limit 1; The INTO clause can name a list of one or more variables, which can be user-defined variables, stored procedure or function parameters, or stored program local variables. Read more about it here. P.S.: Note, that I added LIMIT 1 to the queries. Otherwise an error would be thrown that the query returns more than one row. The difference to select @sq := sq from a_nice_table where id = @a_nice_var; is, that the @sq := sq is done for every row (if there are multiple), but in the end the variable will hold the value

Categories : Mysql

How can I use the get() function to turn the answer in the entry() box into a string
You're right about using get()! The syntax in this case would be City = Cap_Austria.get() if City == 'Vienna': #do stuff You can make default text: Cap_Austria.insert(0, 'default text') And even follow this template: class EntryTemplate(Entry): def __init__(self, master, status): Entry.__init__(self, master) Entry.insert(self, 0, status) Entry.bind(self, "<FocusIn>", lambda event: self.clickOnEntry(event, status)) Entry.bind(self, "<FocusOut>", lambda event: self.clickOffEntry(event, status)) def clickOnEntry(self, event, defaultText): if self.get() == defaultText: self.delete(0, END) def clickOffEntry(self, event, defaultText): if len(self.get()) == 0: Entry.insert(self, 0,

Categories : Python

Oracle Comma Separated Value (ID) in a Column. How to get Description for each Value in a Comma Separated string.
Given below is the query to get comma seperated employee ids in form of rows which I put in subquery to get their name. Please edit as per your ewquirements. Select Ename from employee where employee_id in ( SELECT trim(x.column_value.extract('e/text()')) COLUMNS from awards t, table (xmlsequence(xmltype('<e><e>' || replace(Employee,':','</e><e>')|| '</e></e>').extract('e/e'))) x )

Categories : Oracle

The string constant beginning with "')" does not have an ending string delimiter
There is a missing ' - this is better: insert into employee values ('&v_emp_id','&v_emp_name','&v_address','&v_tel_no','&v_dob','&v_stor_id'); ^

Categories : SQL

Convert Colon Separated String to a Dictionary
string s = "Number1.pdf:Alpha1.pdf; Number2.pdf:Alpha2.pdf; Number3.pdf:Alpha3.pdf;"; var names = s.Replace(".pdf","") .Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .Select(x => x.Split(':')) .ToDictionary(x => x[0].Trim(), x => x[1]);

Categories : C#

sort string with delimiter as string in unix
Temporarily split the info into multiple lines so you can sort: tr ^ \n | sort | tr \n ^ Note: if you have multiple entries, you have to write a loop, which processes it per line.. with huge datasets this is probably not a good idea (too slow), in which case pick a programming language.. but you were asking about the shell...

Categories : Shell

Need to parse the string separated by colon and eliminate part of the string if found the match in plsql
EDIT (simplified) Perhaps this is what you need: SELECT REGEXP_REPLACE(REPLACE('abc:defg:klmnop', ':defg:', ':'), '(^defg:|:defg$)', '') , REGEXP_REPLACE(REPLACE('defg:klmnop:abc', ':defg:', ':'), '(^defg:|:defg$)', '') , REGEXP_REPLACE(REPLACE('abc:klmnop:defg', ':defg:', ':'), '(^defg:|:defg$)', '') , REGEXP_REPLACE(REPLACE('abc:klmnop:defgb:defg', ':defg:', ':'), '(^defg:|:defg$)', '') FROM DUAL ; which removes defg from start, middle, and end, and ignores defgb, giving: abc:klmnop klmnop:abc abc:klmnop abc:klmnop:defgb And to update the table, you could: UPDATE my_table SET value = REGEXP_REPLACE(REGEXP_REPLACE(value, ':defg:', ':'), '(^defg:|:defg$)', '') -- WHERE REGEXP_LIKE(value, '(^|.*:)defg(:.*|$)') WHERE value LIKE '%defg%' ; (though that final r

Categories : Regex

Extract number sets from string, and return as comma seperated values in new string
You could try this UDF: Public Function GetNumbers(sMark As String) As String 'regexp declaration Dim objRegExp As Object Set objRegExp = CreateObject("vbscript.regexp") With objRegExp .Global = True .Pattern = "(d+)D*" Dim i As Long If .Execute(sMark).Count > 1 Then For i = 0 To .Execute(sMark)(0).submatches.Count GetNumbers = GetNumbers & .Execute(sMark)(i).submatches(0) & "," Next Else GetNumbers = .Execute(sMark)(0).submatches(0) & "," End If End With GetNumbers = Left(GetNumbers, Len(GetNumbers) - 1) End Function it's tried and tested for examples you provided and hope it will work for all situations you need.

Categories : Excel

Ensure splitting comma separated string with numbers in string
If the source string cannot be changed I would split on letters: v.Split(new[] {'A', 'B', 'C', 'D'}); or v.Split(new[] {"A:", "B:", "C:", "D:"}); and than tidied up the resulting parts.

Categories : C#

Regex match string UNTIL string in a comma separated line
Just use the following. Match from Passed, then everything, until Unique Passed.*Unique if [[ $line =~ Passed.*Unique ]]; then echo line matched $line done; fi EDIT: Since op revised his question to be a comma separated line. line=PassedShownWeekUnique,PassedShownDayUnique,PassedFailedWeek,PassedFailedDayUnique,Passed1Week,Passed1WeekUnique REGEX=Passed.*Unique IFS=','; for word in $line; do if [[ $word =~ $REGEX ]]; then echo matched $word fi done Output: matched PassedShownWeekUnique matched PassedShownDayUnique matched PassedFailedDayUnique matched Passed1WeekUnique

Categories : Regex

Using sed to split a string with a delimiter
You missed the g after the substitution. Hence, it is just done once. See: $ echo "string1:string2:string3:string4:string5" | sed s/:/\n/g string1 string2 string3 string4 string5 g stands for global and means that the substitution has to be done globally, that is, for any occurrence. See that the default is 1 and if you put for example 2, it is done 2 times, etc. All together, in your case you would need to use: sed 's/:/\n/g' ~/Desktop/myfile.txt Note that you can directly use the sed ... file syntax, instead of unnecessary piping: cat file | sed.

Categories : Linux

Add delimiter in string coming from url in PHP
Try using str_getcsv or explode. <?php $data_from_url = "Merchant Id|Merchant|Website|Transaction In Period|Voids In Period|Gross Sales Amount|Total Commision in Period 9766|Mountains Plus Outdoor Gear|www.MPGear.com|1|0|88.91|8.89 12447|Meritline.com|www.meritline.com|5|0|52.86|3.71 16213|East Coast Fashions|www.discountstripper.com|1|0|32.27|3.23 17226|HRM USA|www.HeartRateMonitorsUSA.com|1|0|189.9|6.65"; $splitted_data = explode(PHP_EOL, $data_from_url); /** * print_r($splitted_data) will be * Array * ( [0] => "Merchant Id|Merchant|Website|Transaction In Period|Voids In Period|Gross Sales Amount|Total Commision in Period" [1] => "9766|Mountains Plus Outdoor Gear|www.MPGear.com|1|0|88.91|8.89" ... * ) */ // Y

Categories : PHP

How to tell which delimiter string was split on
Why don't you just run the split twice, once with the first delimiter, then again with the second delimiter? var firstDelimiterItems = page.PageText.Split("First String Delimiter"); var secondDelimiterItems = page.PageText.Split("Second String Delimiter");

Categories : C#

Splitting a string with delimiter in C++
Generally speaking, a string is a char pointer. So you should search for the first character in the delimeter, then check the very next character. Also in looking at your code I am not sure that while (0 != *str++) is doing what you think it is. I think you mean for it to be null terminated.

Categories : C++

Removing text between "|" delimiter and "," delimiter using shell script
Try sed: sed "s/|[^,]*//g" Result: h2co3-macbook:~ h2co3$ echo "name,title,email1|email2|email3,phone,address" | sed "s/|[^,]*//g" name,title,email1,phone,address h2co3-macbook:~ h2co3$

Categories : Regex

fstream with a string delimiter or two char
If you have always have => as the deliminator, you can write a function that will parse lines of the document. void Parse(ifstream& i) { string l; while(getline(i,l)) { //First part string first = l.substr(0, l.find("=>")); //Second part string second = l.substr(l.find("=>")+2, l.length()); //Do whatever you want to do with them. } }

Categories : C++

Splitting a string based on delimiter in C
Use strtok() in string.h header file can be used in C. strtok(char * array, ","); char * array[size of columns][size of rows] pch = strtok (str,","); int i, j; while (pch != NULL) { array[i++][j] = pch; if( i == size of columns - 1){ i = 0; j++; } pch = strtok (NULL, ","); if(j == size of rows -1){ break; } }

Categories : C

PIG - Defining the delimiter used for a bag after a GROUP function
This seems to be an open issue (as of June 2013) in Pig. See the corresponding JIRA for more details. Until the issue is fixed, you can change your input data.

Categories : Apache

Split at multiple delimiter without delimiter in the list
As arshajii points out, you don't need groups at all for this particular regexp. If you did need groups to express a more complex regexp, you could use noncapturing groups to split without capturing the delimiter. It's potentially useful for other situations but syntactically messy overkill here. (?:...) A non-capturing version of regular parentheses. Matches whatever regular expression is inside the parentheses, but the substring matched by the group cannot be retrieved after performing a match or referenced later in the pattern. http://docs.python.org/2/library/re.html So the unnecessarily complex but demonstrative example here would be: re.split(r'(?:[|])', data2)

Categories : Python

Unix separate string line with delimiter
This can make it: while IFS=';' read -r val1 val2 val3 val4 do echo "val1 = $val1" echo "val2 = $val2" echo "val3 = $val3" echo "val4 = $val4" done < input.txt The basic aspect to take into consideration is IFS=";" which defines the Input Field Separator. With read -r val1 .. val4 we indicate which variables will be defined. It can be easier with awk: $ awk -F";" '{for (i=1; i<NF; i++) {print "val"i,"=",$i}}' input.txt It basically defines ; as field separator with the -F ";". Then loops through all these fields with the for i and prints them. NF indicates the number of fields and The loop is up to NF-1 so that the last empty one is not shown. Thanks JS웃 for the tip :) Test $ while IFS=';' read -r val1 val2 val3 val4; do echo "val1 = $val1"; echo "val2 = $val2"; e

Categories : Unix

preg_split expression to split the string by a delimiter
You don't need to escape the quotes, and your split is incorrect anchored at the beginning of the string. Try this: $line = '"name" "Brand" "EAN" "shipping" "Combinable"'; $lineArray = preg_split('/"s+"/', $line); Note that this causes the first element to start with a quote, and the last element to end with a quote. To keep the quotes, use assertions: $lineArray = preg_split('/(?<=")s+(?=")/', $line); This produces a $lineArray like (note how it kept the quotes): Array ( [0] => "name" [1] => "Brand" [2] => "EAN" [3] => "shipping" [4] => "Combinable" )

Categories : PHP

Split a string with a word for delimiter in batch
@ECHO OFF SETLOCAL SET string=C:Dir1Dir2Dir3File.c SET divider=Dir2 CALL SET after=%%string:*%divider%=%% CALL SET before=%%string:%divider%%after%=%% ECHO before=+%before%+ ECHO divider=+%divider%+ ECHO after=+%after%+ GOTO :eof Test output: before=+C:Dir1+ divider=+Dir2+ after=+Dir3File.c+ + was included simply to demonstrate that there are no stray spaces involved.

Categories : Windows

parse a string in javascript by a common delimiter
var str="/john/smith" var ar=str.split("/"); now ar[1] will contain firstname & ar[2] will contain lastname

Categories : Javascript

php explode not working as expected with string as a delimiter
When your code echo end(explode('Item description', $body)); return everything or all $body as string that mean 'Item description' not found . And When return empty string that mean the last element of return array is empty string

Categories : PHP

XSLT - Wrapping up of string after delimiter count 5 (e.g. 5 "|")
If you can use XSLT 2.0, you could use tokenize(). Example ($input is the string in your question): <xsl:value-of select="tokenize($input,'|')[5 >= position()]" separator="|"/> This will produce: Jason|Michael|John|James|Rick

Categories : Xslt

split string based on comma delimiter
You have to escape square brackets because replaceAll() interprets the first argument as a regular expression: replaceAll("\[", "") ^^ because, as the error message tells you, the are used for character classes in a regex. Double backslashes are necessary, because "[" would be an invalid escape sequence. Since the backslash is escaped, the regex engine only receives one backslash. Also, you can use replace("[", "") it will also replace all occurrences of the given CharSequence as is. You can read more about it in JavaDoc.

Categories : Java

How can I write a string array to Excel file, with a tab delimiter?
This may help you. The way I created excel file is to read the string from the file and message the data and separated with , and save as .csv file. May be in your case try to replace the with the , and then try to create the file. This code may give you an idea. I haven't tested it though. 1 string filePath = @"C: est.csv"; 2 string delimiter = ","; 3 4 string[][] output = new string[][]{ 5 new string[]{"Col 1 Row 1", "Col 2 Row 1", "Col 3 Row 1"}, 6 new string[]{"Col1 Row 2", "Col2 Row 2", "Col3 Row 2"} 7 }; 8 int length = output.GetLength(0); 9 StringBuilder sb = new StringBuilder(); 10 for (int index = 0; index < length; index+

Categories : C#

String manipulation: Display all characters to the left of "|" delimiter
You can use String.IndexOf() to find the index of a character in a string: Dim employeeID = Microsoft.VisualBasic.Left(employeeInfo, employeeInfo.IndexOf("|")) Note that String.IndexOf() will return -1 if the string does not contain the character that you request. If you are not sure that your string will always contain the | you will need to test the return value of String.IndexOf().

Categories : Vb.Net

php explode: split string into words by using space a delimiter
For splitting the String into an array, you should use preg_split: $string = 'This is a string'; $data = preg_split('/s+/', $string); Your second part (counting spaces): $string = 'This is a string'; preg_match_all('/s+/', $string, $matches); $result = array_map('strlen', $matches[0]);// [1, 1, 4]

Categories : PHP

Remove first two blocks based on delimiter from multiline string
Ooh! This is a perfect case for String.split, Array.map, and Array.join. I do this kind of stuff all the time: data = data.split(" ").map(function(entry) { return entry.replace(/^d{2}/d{2}/d{2} d{2}:d{2}:d{2} [A-F0-9]+ /, ""); }).join(" "); String.split will split the string into an array based on a substring or regex (for us, ) Array.map will run a function over each element in the array, returning a new array of the return values of the function Array.join will join an array with a string (in our case, ) EDIT: You could probably just use entry.substr(29) instead of that regex, as well. false: the question specifically states that the third block to get rid of is of a variable length. DOUBLE EDIT: In your case, you could probably just use a straight regex, instead, as other peo

Categories : Javascript

Regex for fixed string followed by characters up to a delimiter character
Put everything except comma in a saving group: match = re.search(r'(FullName=.+?),', str) if match: print match.group(1) ##'found a match' else: print 'ainnussin zer' prints FullName=TECIBW04 TECIBW04

Categories : Python

Split all characters in a string with no delimiter into an array with lotus notes
@Explode uses as delimiters space, comma and semicolon if second parameter is empty. That doesn't help you in your case. Just use "normal" string functions like substring(): function test() { var strString = "thisIsTheString"; var strReturn = ""; for (var i = 0; i < strString.length; i++) { strReturn += strString.substring(i, i+1) + "<br/>"; } return strReturn; } In case you really need an array of characters then code would look like this: var strString = "thisIsTheString"; var arrayReturn = new Array(); for (var i = 0; i < strString.length; i++) { arrayReturn[i] = strString.substring(i, i+1); }

Categories : Javascript

bash, extract string from text file with space delimiter
use awk for this: awk '/MC exp. sig-250-0/ {print $10}' your.txt Note that this will print: $3.57 - with the leading $, if you don't like this, pipe the output to tr: awk '/MC exp. sig-250-0/ {print $10}' your.txt | tr -d '$' In comments you wrote that you need to call it in a script like this: while read p ; do echo $p,awk '/MC exp. sig-$p/ {print $10}' filename | tr -d '$' done < grid.txt Note that you need a sub shell $() for the awk pipe. Like this: echo "$p",$(awk '/MC exp. sig-$p/ {print $10}' filename | tr -d '$') If you want to pass a shell variable to the awk pattern use the following syntax: awk -v p="MC exp. sig-$p" '/p/ {print $10}' a.txt | tr -d '$'

Categories : String

SQL Trigger to split string during insert without a common delimiter and store it into another table
You could use 'set' as a delimiter. This is a simple sample. It obviously may have to be molded to your environment. use tempdb GO IF OBJECT_ID('dbo.fn_TVF_Split') IS NOT NULL DROP FUNCTION dbo.fn_TVF_Split; GO CREATE FUNCTION dbo.fn_TVF_Split(@arr AS NVARCHAR(2000), @sep AS NCHAR(3)) RETURNS TABLE AS RETURN WITH L0 AS (SELECT 1 AS C UNION ALL SELECT 1) --2 rows ,L1 AS (SELECT 1 AS C FROM L0 AS A, L0 AS B) --4 rows (2x2) ,L2 AS (SELECT 1 AS C FROM L1 AS A, L1 AS B) --16 rows (4x4) ,L3 AS (SELECT 1 AS C FROM L2 AS A, L2 AS B) --256 rows (16x16) ,L4 AS (SELECT 1 AS C FROM L3 AS A, L3 AS B) --65536 rows (256x256) ,L5 AS (SELECT 1 AS C FROM L4 AS A, L4 AS B) --4,294,967,296 rows (65536x65536) ,Nums AS (SELECT row_number() OVER (ORDER BY (SELECT 0)) AS

Categories : SQL



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.