To regexp two number separated by \

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To regexp two number separated by \
# 1  
Old 06-03-2011
To regexp two number separated by \

Hi All,

I want to extract the numbers which are separated by "/". For example if I have expression like :
Score = 13/11

I want to extract 13 & 11.

Can someone please help with regexp string.

Really appreciate your help

# 2  
Old 06-03-2011

# 3  
Old 06-03-2011
Based on your sample data, here is one solution:
sed -e 's#.* \(.*\)/\(.*\)#\1 \2#' input_file

# 4  
Old 06-03-2011
[My bad for putting wrong output Smilie]
Hi DGPickett

It ain't working :

expect1.3> regexp {\([0-9][\{1,9\}\)[/]\([0-9][\{1,9\}\)} $a match1 match2
couldn't compile regular expression pattern: brackets [] not balanced
while executing

Last edited by ratneshnagori; 06-03-2011 at 01:17 PM.. Reason: Wrong Output
# 5  
Old 06-03-2011
Score="13/11"echo "$Score" | cut -d"/" -f1echo "$Score" | cut -d"/" -f2
# 6  
Old 06-03-2011
Works in sed -- regex is a layered thing, need to turn on extended regex.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to parse comma separated field and removing comma in between number and double quotes

Hi Experts, Please support I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6. ... (3 Replies)
Discussion started by: as7951
3 Replies

2. What is on Your Mind?

A Regexp You Can Use Everywhere

\_(ツ)_/ bakunin (0 Replies)
Discussion started by: bakunin
0 Replies

3. Shell Programming and Scripting


I would like to extract "1333 Fairlane" given the below text. The word "Building:" is always present. The wording between Building and the beginning of the address can be almost anything. It appears the the hyphen is there most of the time. Campus: Fairlane Business Park Building:... (9 Replies)
Discussion started by: bbaker@copesan.
9 Replies

4. UNIX for Dummies Questions & Answers

[solved] Comma separated values to space separated

Hi, I have a large number of files which are written as csv (comma-separated values). Does anyone know of simple sed/awk command do achieve this? Thanks! ---------- Post updated at 10:59 AM ---------- Previous update was at 10:54 AM ---------- Guess I asked this too soon. Found the... (0 Replies)
Discussion started by: lost.identity
0 Replies

5. Shell Programming and Scripting

Regexp to separated rows by "asterisks-new line" in awk

Hello to all, I have the text file below, how would be the REGEXP to set the RS to separate registers by asterisks-newline-asterisks (highlighted in red) and FS as the default, in order that the fourth field ($4) always be the number after REG (in blue)? I'm trying with code below, but is... (5 Replies)
Discussion started by: Ophiuchus
5 Replies

6. UNIX for Dummies Questions & Answers

print the line immediately after a regexp; but regexp is a sentence

Good Day, Im new to scripting especially awk and sed. I just would like to ask help from you guys about a sed command that prints the line immediately after a regexp, but not the line containing the regexp. sed -n '/regexp/{n;p;}' filename What if my regexp is 3 word or a sentence. Im... (3 Replies)
Discussion started by: ownins
3 Replies

7. Shell Programming and Scripting

Help with regexp

Hi there! I would like to know how to find and replace all numbers in a *.html file and make them bold. Any help will be appreciated! :) (7 Replies)
Discussion started by: agasamapetilon
7 Replies

8. Shell Programming and Scripting

Parse apart strings of comma separated data with varying number of fields

I have a situation where I am reading a text file line-by-line. Those lines of data contain comma separated fields of data. However, each line can vary in the number of fields it can contain. What I need to do is parse apart each line and write each field of data found (left to right) into a file.... (7 Replies)
Discussion started by: 2reperry
7 Replies

9. Shell Programming and Scripting

regexp help

I'd like to know if there is a catchall line for renaming the following patterns: s01e03 -> 01x03 s4e9 -> 04x09 s10e08 ->10x08 and possibly even: 318 -> 03x18 1002 ->10x02 if its the first 3 or first digit number in the string. thanks! (0 Replies)
Discussion started by: TinCanFury
0 Replies

10. UNIX for Advanced & Expert Users


Hi guys, does anyone know how to test for a regular expression - i want to include it in a script to make sure the variable is a regexp cheers (1 Reply)
Discussion started by: penfold
1 Replies
Login or Register to Ask a Question