Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Regular Expressions -- Find spaces outside Post 302449164 by Scott on Saturday 28th of August 2010 07:29:41 PM
Old 08-28-2010
Hi.

Would this work?

Code:
$ awk -F"(" -v OFS="(" 'gsub(/ +/, "\t", $1)' file1
意文	yìwén	(given name)
貴姓	guìxìng	(honorable surname)
貴	guì	(honorable)
姓	xìng	(one's surname is; to be surnamed; surname)
呢	ne	(interrogative particle)
叫	jiào	(to be called; to call)
名字	míngzi	(name)

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular Expressions

I'm trying to parse RichText to XML. I want to be able to capture everything between the '/par' tag in the RTF but not include the tag itself. So far all I have is this, '.*?\\par' but it leaves '\par' at the end of it. Any suggestions? (1 Reply)
Discussion started by: AresMedia
1 Replies

2. Shell Programming and Scripting

Regular Expressions

How can i create a regular expression which can detect a new line charcter followed by a special character say * and replace these both by a string of zero length? Eg: Input File san.txt hello hi ... (6 Replies)
Discussion started by: sandeep_hi
6 Replies

3. Shell Programming and Scripting

regular expressions

Hi, can anyone advise me how to shorten this: if || ; then I tried but it dosent seem to work, whats the correct way. Cheers (4 Replies)
Discussion started by: jack1981
4 Replies

4. UNIX for Dummies Questions & Answers

regular expressions

Hi Gurus, I need help with regular expressions. I want to create a regular expression which will take only alpha-numeric characters for 7 characters long and will throw out an error if longer than that. i tried various combinations but couldn't get it, please help me how to get it guys. ... (2 Replies)
Discussion started by: ragha81
2 Replies

5. UNIX for Dummies Questions & Answers

regular expressions

how to find for a file whose name has all characters in uppercase after 'project'? I tried this: find . -name 'project**.pdf' ./projectABC.pdf ./projectABC123.pdf I want only ./projectABC.pdf What is the regular expression that correponds to "all characters are capital"? thanks (8 Replies)
Discussion started by: melanie_pfefer
8 Replies

6. Shell Programming and Scripting

Need help with Regular Expressions

Hi, In ksh, I am trying to compare folder names having -141- in it's name. e.g.: 4567-141-8098 should match this expression '*-141-*' but, -141-2354 should fail when compared with '*-141-*' simlarly, abc should fail when compared with '*-141-*' I tried multiple things but nevertheless,... (5 Replies)
Discussion started by: jidsh
5 Replies

7. Shell Programming and Scripting

Regular Expressions

what elements does " /^/ " match? I did the test which indicates that it matches single lowercase character like 'a','b' etc. and '1','2' etc. But I really confused with that. Because, "/^abc/" matches strings like "abcedf" or "abcddddee". So, what does caret ^ really mean? Any response... (2 Replies)
Discussion started by: DavidHe
2 Replies

8. Shell Programming and Scripting

Help with regular expressions

I have a file that I'm trying to find all the cases of phone number extensions and deleting them. So input file looks like: abc x93825 def 13234 x52673 hello output looks like: abc def 13234 hello Basically delete lines that have 5 numbers following "x". I tried: x\(4) but it... (7 Replies)
Discussion started by: pxalpine
7 Replies

9. UNIX for Advanced & Expert Users

Using find and regular expressions

Hi Could you please advise how can one extract from the output of find . -name "*.c" -print only filenames in the current direcotry and not in its subdirectories? I tried using (on Linux x86_64) find . -name "*.c" -prune but it is not giving correct output. Whereas I am getting... (9 Replies)
Discussion started by: tinku981
9 Replies

10. Shell Programming and Scripting

Replacing Multiple spaces with a single space but excluding few regular expressions

Hi All. Attached are two files. I ran a query and have the output as in the file with name "FILEWITHFOURRECORDS.txt " I didn't want all the spaces between the columns so I squeezed the spaces with the "tr" command and also added a carriage return at the end of every line. But in two... (3 Replies)
Discussion started by: sparks
3 Replies
SSCANF(3)								 1								 SSCANF(3)

sscanf - Parses input from a string according to a format

SYNOPSIS
mixed sscanf (string $str, string $format, [mixed &$...]) DESCRIPTION
The function sscanf(3) is the input analog of printf(3). sscanf(3) reads from the string $str and interprets it according to the specified $format, which is described in the documentation for sprintf(3). Any whitespace in the format string matches any whitespace in the input string. This means that even a tab in the format string can match a single space character in the input string. PARAMETERS
o $str - The input string being parsed. o $format - The interpreted format for $str, which is described in the documentation for sprintf(3) with following differences: o Function is not locale-aware. o F, g, G and b are not supported. o D stands for decimal number. o i stands for integer with base detection. o n stands for number of characters processed so far. o $... - Optionally pass in variables by reference that will contain the parsed values. RETURN VALUES
If only two parameters were passed to this function, the values parsed will be returned as an array. Otherwise, if optional parameters are passed, the function will return the number of assigned values. The optional parameters must be passed by reference. If there are more substrings expected in the $format than there are available within $str, -1 will be returned. EXAMPLES
Example #1 sscanf(3) Example <?php // getting the serial number list($serial) = sscanf("SN/2350001", "SN/%d"); // and the date of manufacturing $mandate = "January 01 2000"; list($month, $day, $year) = sscanf($mandate, "%s %d %d"); echo "Item $serial was manufactured on: $year-" . substr($month, 0, 3) . "-$day "; ?> If optional parameters are passed, the function will return the number of assigned values. Example #2 sscanf(3) - using optional parameters <?php // get author info and generate DocBook entry $auth = "24 Lewis Carroll"; $n = sscanf($auth, "%d %s %s", $id, $first, $last); echo "<author id='$id'> <firstname>$first</firstname> <surname>$last</surname> </author> "; ?> SEE ALSO
fscanf(3), printf(3), sprintf(3). PHP Documentation Group SSCANF(3)
All times are GMT -4. The time now is 09:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy