Perl removing strings from a variable value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl removing strings from a variable value
# 1  
Old 07-27-2010
Power Perl removing all strings but the final few characters from a variable value

Dear all,

I have a variable called $abc, which the value is something like below,

*** *********** : *****

where * can be anything. I need to remove all but the final characters until last whitespace.

example

grd groupstudy : tutor6/7

becomes tutor6/7

something like
Code:
if $myvalue=1 {

modify $abc as mentioned above and the new value becomes $myvalue2.
$abc value remains unchanged.

}

thank you for your kind help!. Smilie

Last edited by tententen; 07-27-2010 at 07:47 AM..
# 2  
Old 07-27-2010
Code:
$abc='grd groupstudy : tutor6/7';
if ( $abc=~/(.+?)\s(.+?)\s:\s(.*)/) { $myvalue2=$3;}

# 3  
Old 07-27-2010
MySQL

Thx for the fast respond!.

Last edited by tententen; 07-27-2010 at 08:53 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help with using strings in variable

Hi, I am calling a in-house built api from unix shell script for posting some comments on jira. Facing some problem in handling variables could someone give some insights here. #1) Below is working I have declared a variable called var=testing and used that var in my api it works fine. ... (1 Reply)
Discussion started by: close2jai
1 Replies

2. Shell Programming and Scripting

Removing string between two particular strings in a line

Hi, I have a file with following format: 1|What is you name (full name)?|Character 2|How far is your school ?|Numeric Now I need to remove everything inside brackets () or . There can be more than one pair of brackets. The output file should look like: 1|What is you name?|Character... (8 Replies)
Discussion started by: ppatra
8 Replies

3. Shell Programming and Scripting

script in perl for removing strings between a file

I have file that looks like: ATOM 2517 O VAL 160 8.337 12.679 -2.487 ATOM 2518 OXT VAL 160 7.646 12.461 -0.386 TER ATOM 2519 N VAL 161 -14.431 5.789 -25.371 ATOM 2520 H1 VAL 161 -15.336 5.698 -25.811 ATOM 2521 H2 VAL 161 -13.416 10.529 17.708 ATOM 2522 H3 VAL 161 -14.363 ... (4 Replies)
Discussion started by: kanikasharma
4 Replies

4. SuSE

finding and removing block of identical strings

i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings... for example the awk code removing consecutive identical word is:... (2 Replies)
Discussion started by: cocostaec
2 Replies

5. Programming

finding and removing block of identical strings

i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings... for example the awk code removing consecutive identical word is:... (2 Replies)
Discussion started by: cocostaec
2 Replies

6. Shell Programming and Scripting

finding and removing block of identical strings

i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings... for example the awk code removing consecutive identical word is:... (2 Replies)
Discussion started by: cocostaec
2 Replies

7. Shell Programming and Scripting

Removing a character from a variable and assigning it to another variable?

Hi folks. I have this variable called FirstIN that contains something like this: 001,002,003,004... I am trying to assign the content of this variable into ModifiedIN but with the following format : 001 002 003 004...(changing the commas for spaces) I thought about using sed but i am not... (17 Replies)
Discussion started by: Stephan
17 Replies

8. Shell Programming and Scripting

Removing text between two static strings

Hi everyone, I need to replace the text between two strings (html tags) and I'm having trouble figuring out how to do so. I can display the text with sed but I'm not having any luck deleting the text between the two strings. My file looks like this: <oths>test</oths><div class="text">1928... (2 Replies)
Discussion started by: cg2
2 Replies

9. Shell Programming and Scripting

bash hell , removing " and adding from a strings

I'm writing a bash script and i'm stuck the out put of a dialog menu is echo $select "foo" "bar" "lemon" cheese" while I need $foo $bar $lemon $cheese to reuse them as strings later in the script and very new to bash scripting and i've no idea how to do this any help would be... (2 Replies)
Discussion started by: xpd259
2 Replies

10. Shell Programming and Scripting

appending strings to variable

is it possible? as i keep reading a file, i want one particular variable to keep storing the line that i've read so far (1 Reply)
Discussion started by: finalight
1 Replies
Login or Register to Ask a Question