Sponsored Content
Top Forums Shell Programming and Scripting Extract the string between 2 delimiters Post 303044297 by vgersh99 on Tuesday 18th of February 2020 09:18:47 AM
Old 02-18-2020
how about for starters:
Code:
echo 'https://example.com/live-hls/bla:bob-sd-blabla/playlist.m3u8' | sed 's#.*:\([^-][^-]*\)-.*#\1#'

These 2 Users Gave Thanks to vgersh99 For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

To extract everything between two delimiters

My input file looks like " @$SCRIPT/atp_asrmt_adj.sql $SCRIPT/dba2000.scr -s / @$SCRIPT/cim1005w.pls $SCRIPT/dba2000.scr -s / @$SCRIPT/cim1006w.pls start $SCRIPT/cim1020d.sql;^M spool $DATA/cim1021m.sql @$DATA/cim1021m.sql ! rm $DATA/cim1021m.sql spool $DATA/cim1021m.sql... (1 Reply)
Discussion started by: dowsed4u8
1 Replies

2. UNIX for Advanced & Expert Users

extract text b/w two delimiters

I have an input file which looks like " @$SCRIPT/atp_asrmt_adj.sql $SCRIPT/dba2000.scr -s / @$SCRIPT/cim1005w.pls $SCRIPT/dba2000.scr -s / @$SCRIPT/cim1006w.pls start $SCRIPT/cim1020d.sql;^M spool $DATA/cim1021m.sql @$DATA/cim1021m.sql ! rm $DATA/cim1021m.sql spool $DATA/cim1021m.sql... (6 Replies)
Discussion started by: dowsed4u8
6 Replies

3. Shell Programming and Scripting

how to extract values b/w two delimiters

Hi, Please help me to extrat values b/w two delimiters. $ echo $abc i want to extract the value 12345 b/w %. (5 Replies)
Discussion started by: tsaravanan
5 Replies

4. Shell Programming and Scripting

sub-string extract between variable delimiters

I need to extract certain pieces from a string, wher delimiters may vary. For example A0 B0 C0 12345677 X0 Y0 Z0 A1-B1 C1 12345678 X1 Y0 Z0 A1/B2 C77 12345679 X2 Y0 Z0 I need to get C0 12345677 X0 C1 12345678 X1 C77 12345679 X2 I tried sed, see example below: echo 'A0 B0... (2 Replies)
Discussion started by: migurus
2 Replies

5. Shell Programming and Scripting

Getting a string without fixed delimiters

I have a line of text for example aaaa bbbb cccc dddd eeee ffffff I would need to get the cccc however bbbb could be there or not. So whether bbbb is in the line or not I need cccc. I was looking at either awk or sed....and trying to start at c and end until the next space. Also... (11 Replies)
Discussion started by: bombcan1
11 Replies

6. Shell Programming and Scripting

Extract strings within XML file between different delimiters

Good afternoon! I have an XML file from which I want to extract only certain elements contained within each line. The problem is that the format of each line is not exactly the same (though similiar). For example, oa_var will be in each line, however, there may be no value or other... (3 Replies)
Discussion started by: bab@faa
3 Replies

7. Shell Programming and Scripting

How to Replace string between delimiters?

Basically , i want to delete strings of a particular pattern from the flat file which is " | " pipe delimited. Below are the valid formats : 1) AAA (0) 111-111-111, AAA, BB 2) AAA (0) 111-111-1111;X, AAA, BB original flat file example : |ABC ABC XHAMK|AAA (0) 111-111-111, AAA,... (3 Replies)
Discussion started by: Ravi_007
3 Replies

8. Shell Programming and Scripting

Extract value between the delimiters and replace it with another value

Hi All, i have file name like below ABC_065224_123456_123456_your_130413_163005.txt ABC_065224_123456_MAIN_20130413_163005.txt ABC_065224_123456_123456_MAIN_130413_163005.txt ABC_065224_123456_123456_434567_MAIN_130413_163005.txt i need to find out the number of characters in the filed... (6 Replies)
Discussion started by: dssyadav
6 Replies

9. Shell Programming and Scripting

Skip the delimiter with in double quotes and count the number of delimiters during data extract

Hi All, I'm stuck-up in finding a way to skip the delimiter which come within double quotes using awk or any other better option. can someone please help me out. Below are the details: Delimited: | Sample data: 742433154|"SYN|THESIS MED CHEM PTY.... (2 Replies)
Discussion started by: BrahmaNaiduA
2 Replies

10. Shell Programming and Scripting

How to replace string between delimiters?

Hello, I would need to replace a delimiter in a flat file using.I would like to replace the semicolon (";") but only if it was contained in a string between quotes. For example: Original flat file example: abc;abc;"abc;abc";cd;"ef;ef";abc aa;bb;"aa";cc;"ddd;eee";ff Desired output:... (9 Replies)
Discussion started by: bartleby
9 Replies
wcstok(3)						     Library Functions Manual							 wcstok(3)

NAME
wcstok, wcstok_r - Split wide-character strings into tokens LIBRARY
Standard C Library (libc) SYNOPSIS
wchar_t *wcstok( wchar_t *ws1, const wchar_t *ws2), wchar_t **savept); This prototype conforms to both ISO C and XSH Issue 5 and is strongly recommended for new applications. The wcstok() function supported in compilation environments for XSH versions earlier than XSH Issue 5 does not include the savept parameter, which is required for threadsafe operation. The following proprietary prototype is the threadsafe interface that was supported on Tru64 UNIX versions prior to Version 4.0 and is supported only to provide backward compatibility for applications written before the ISO C and XSH5 threadsafe prototype was avail- able. wchar_t *wcstok_r( wchar_t *ws1, const wchar_t *ws2), wchar_t **savept); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: wcstok(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Contains a pointer to the wide-character string to be searched. Contains a pointer to the string of wide-character token delimiters. Identifies the location of the wide character where the search for tokens should be started in the next call. The savept parameter contains a pointer to a variable that contains a pointer to the wide character where scanning begins. DESCRIPTION
The wcstok() function splits the wide-character string pointed to by the ws1 parameter into a sequence of tokens, each of which is delim- ited by a wide character from the wide-character string pointed to by the ws2 parameter. Usually, the wcstok() function is called repeatedly to extract the tokens in a wide-character string. On the first call to the wcstok() function, the application sets the ws1 parameter to point to the input wide-character string. The function returns a pointer to the first token. The application program calls the function again with the ws1 parameter set to the null pointer. This call returns a pointer to the next token in the string. The application program repeats the call to wcstok() with the ws1 parameter set to the null pointer until all the tokens in the string have been returned. On the initial call to wcstok(), the function first searches the wide-character string pointed to by the ws1 parameter to locate the first wide character that does not occur in the wide-character delimiter string pointed to by the ws2 parameter. If such a wide character is found, it is the start of the first token. The wcstok() function then searches from there for a wide character that does occur in the delimiter string. If such a wide-character delimiter is found, wcstok() overwrites it with a null wide character, which terminates the cur- rent token. The wcstok() function saves a pointer to the wide character following the null wide character and returns a pointer to the start of the token. In subsequent calls to wcstok(), where ws1 is set to a null pointer, the function starts at the saved pointer and searches for the next wide character that does not occur in the wide-character delimiter string pointed to by the ws2 parameter. If such a wide character is found, it is the start of the new token. The wcstok() function then searches from there for a wide character that does occur in the delim- iter string. If such a wide-character delimiter is found, wcstok() overwrites it with a null wide character, which terminates the new token. The wcstok() function saves a pointer to the wide character following the null wide character and returns a pointer to the start of the new token. It stores the saved pointer in the *savept parameter as well as internally. On calls where the s1 parameter is a null pointer, the function uses the saved pointer in *savept to start searching for the next token. Applications that require threadsafe opera- tion must use a wcstok() interface that includes the savept parameter. If a call to the wcstok() function cannot find a wide character that does not occur in the delimiter string, it returns the null pointer. If a call to the wcstok() function cannot find the terminating wide character that does occur in the delimiter string, the current token extends to the end of the string and subsequent calls to wcstok() return the null pointer. If the delimiters used in the wide-character string change from one set of characters to another within the string, the application can set the second parameter, ws2, to different wide-character strings from call to call. The implementation behaves as though no function calls the wcstok() function. EXAMPLES
The following example splits a wide-character string into tokens: #include <wchar.h> #include <locale.h> #include <stdio.h> #define WLENGTH 40 main() { wchar_t WCString1[WLENGTH], delimiters[WLENGTH]; wchar_t * pwcs; int counter; (void)setlocale(LC_ALL, ""); printf("Enter the string to be searched: "); if (fgetws(WCString1, WLENGTH, stdin) != NULL) { printf("Enter the delimiter(s): "); if (fgetws(delimiters, WLENGTH, stdin) != NULL) { if ((pwcs = wcstok(WCString1, delimiters )) != NULL) { /* pwcs points to the first token */ printf("Token 1 is %S ", pwcs); counter = 2; while ((pwcs = wcstok((wchar_t * )NULL, delimiters )) != NULL) { printf("Token %d is %S ", counter, pwcs); counter++; } } } } } RETURN VALUES
On successful completion, the wcstok() function returns a pointer to the first wide character of a token. A null pointer is returned if there is no token. The wcstok() function also sets the pointer *savept to the wide character from which the search for the next token starts, or to a null pointer if there is none. RELATED INFORMATION
Functions: strtok(3), wcspbrk(3), wcsspn(3), wcstod(3), wcstol(3), wcstoul(3) Standards: standards(5) delim off wcstok(3)
All times are GMT -4. The time now is 07:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy