[Solved] Extracting all characters from a string


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Extracting all characters from a string
# 1  
Old 11-09-2011
[Solved] Extracting all characters from a string

I want to extract the string TC from the string TC10, the string can have any characters
out of [ATGC].

I used the following code but didnt get the right output. Please guide

Code:
nuc=match(val,/[ATGC]*/)
seq=substr(val,RSTART,RLENGTH)

---------- Post updated at 09:40 PM ---------- Previous update was at 09:31 PM ----------

sorry, this is solved... it had lowercase characters also :-/
Code:
nuc=match(val,/[ATGCatgc]*/)


Last edited by vbe; 11-10-2011 at 09:57 AM.. Reason: copleted code tags...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Outputting characters after a given string and reporting the characters in the row below --sed

I have this fastq file: @M04961:22:000000000-B5VGJ:1:1101:9280:7106 1:N:0:86 GGGGGGGGGGGGCATGAAAACATACAAACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAATACCATGAAAAATATCAACCACACCA +test-1 GGGGGGGGGGGGGGGGGCCGGGGGFF,EDFFGEDFG,@DGGCGGEGGG7DCGGGF68CGFFFGGGG@CGDGFFDFEFEFF:30CGAFFDFEFF8CAF;;8... (10 Replies)
Discussion started by: Xterra
10 Replies

2. Shell Programming and Scripting

[Solved] Extracting information from DDL's

Dear Experts, I need your help here. I have lot of teradata DDL's as follows, i want to extract field names , field attributes and NOT NULL information from DDL.Could you please help here. Sample DDL: CREATE MULTISET TABLE APS_CALL_IN_PICKUP_CANCELED ,NO FALLBACK , NO BEFORE... (2 Replies)
Discussion started by: srikanth38
2 Replies

3. Shell Programming and Scripting

Extracting characters and storing in some variable

eg: ./myProgram.sh filename.cpp I want to remove the :".cpp" extension from the filename.cpp expected output: filename (3 Replies)
Discussion started by: umesh314
3 Replies

4. UNIX for Dummies Questions & Answers

[Solved] eliminate characters in vi

hey guys. what command in vi editor should I write to make this M83RDK-078A -1 1 1024 1 1024 OK X | M83RDK-055 -1 1 627 1 627 OK X | become like this M83RDK-078A 1 1024 M83RDK-055 1... (5 Replies)
Discussion started by: muhnandap
5 Replies

5. Shell Programming and Scripting

[Solved] Help on extracting the numbers out of top command

Hi guys, Any easy way to generate a CSV file that contains only the numbers out of the following lines? load averages: 15.09, 12.89, 11.76 03:39:22 999 processes: 854 sleeping, 2 running, 122 zombie, 5 stopped, 16 on cpu Memory: 32G real, 17G free, 18G swap in use, 15G swap free ... (6 Replies)
Discussion started by: ejianu
6 Replies

6. Shell Programming and Scripting

[Solved] Extracting data from a determined file

Hi guys, How you doing? Need some help with this .I got a file with this kind of information SURVIVABLE PROCESSORS Name Type IP Address Reg Act Translations Net Updated Rgn Gateway001 ... (8 Replies)
Discussion started by: REX:)
8 Replies

7. Shell Programming and Scripting

Extracting data between two characters

From the command line how would I extract data in file that was contained between parenthesis "()"? Awk or Grep? Thanks in advance Ted (11 Replies)
Discussion started by: TedSD
11 Replies

8. UNIX for Dummies Questions & Answers

extracting few characters from a file

i want to extract few characters from a file based on a special character like || how to do it suggestions please (4 Replies)
Discussion started by: trichyselva
4 Replies

9. Shell Programming and Scripting

Extracting a string from one file and searching the same string in other files

Hi, Need to extract a string from one file and search the same in other files. Ex: I have file1 of hundred lines with no delimiters not even space. I have 3 more files. I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Discussion started by: mohancrr
1 Replies

10. Shell Programming and Scripting

extracting usernames with at least 4 characters

Hi, i want to use grep to extract users with at least 4 characters in their username, i've tried who | grep \{4,\} but thats not working!!!!!! Thanks (4 Replies)
Discussion started by: c19h28O2
4 Replies
Login or Register to Ask a Question
RTRIM(3)								 1								  RTRIM(3)

rtrim - Strip whitespace (or other characters) from the end of a string

SYNOPSIS
string rtrim (string $str, [string $character_mask]) DESCRIPTION
This function returns a string with whitespace stripped from the end of $str. Without the second parameter, rtrim(3) will strip these characters: o " " (ASCII 32 ( 0x20)), an ordinary space. o " " (ASCII 9 ( 0x09)), a tab. o " " (ASCII 10 ( 0x0A)), a new line (line feed). o " " (ASCII 13 ( 0x0D)), a carriage return. o "" (ASCII 0 ( 0x00)), the NULL-byte. o "x0B" (ASCII 11 ( 0x0B)), a vertical tab. PARAMETERS
o $str - The input string. o $character_mask - You can also specify the characters you want to strip, by means of the $character_mask parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters. RETURN VALUES
Returns the modified string. EXAMPLES
Example #1 Usage example of rtrim(3) <?php $text = " These are a few words :) ... "; $binary = "x09Example stringx0A"; $hello = "Hello World"; var_dump($text, $binary, $hello); print " "; $trimmed = rtrim($text); var_dump($trimmed); $trimmed = rtrim($text, " ."); var_dump($trimmed); $trimmed = rtrim($hello, "Hdle"); var_dump($trimmed); // trim the ASCII control characters at the end of $binary // (from 0 to 31 inclusive) $clean = rtrim($binary, "x00..x1F"); var_dump($clean); ?> The above example will output: string(32) " These are a few words :) ... " string(16) " Example string " string(11) "Hello World" string(30) " These are a few words :) ..." string(26) " These are a few words :)" string(9) "Hello Wor" string(15) " Example string" SEE ALSO
trim(3), ltrim(3). PHP Documentation Group RTRIM(3)