Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Other Languages

Reply
 
LinkBack Thread Tools
Old January 11th, 2006, 04:59 AM   #1
WebForumz Member
 

Join Date: Sep 2005
Location: athens
Age: 27
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ktsirig is on a distinguished road
Confused with strings...

Hi all!
I have this assignment to give in Biology class and I am stuck.

Assignment:
I am given a sequence of letters, say:

XXXXXXABCDXXXXXXXX

and I am interested in part ABCD, which represents letters #7-#10 as you can see.

I am then given the same sequence, which now contains characters like * and !(only these 2 are allowed),
say:

XX**XXX!!!X**AB*!C*DXX*!!!XXX**XXX

and I want to find out which letters now represent the part ABCD.
If you count, you see that ABCD is now letters #14-#20 [4*and! were added prior to A and 10 prior to D]

What I think must be done is:
1) check how many (if any) * or/and ! were added prior to start letter A(#7)
2) check how many (if any) * or/and ! were added prior to end letter D(#10)
3) add all * and/or ! to starting and ending letter of part ABCD

Has anyone got any hints to give me as to which functions of Perl will be useful for this problem?
ktsirig is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 11th, 2006, 02:02 PM   #2
Reputable Member
 

Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 grahame is a jewel in the rough grahame is a jewel in the rough grahame is a jewel in the rough
Re: Confused with strings...

Quote:
Originally Posted by ktsirig
Has anyone got any hints to give me as to which functions of Perl will be useful for this problem?
Can'y you just use a regular expression to grab out the section you want and then see how long your PREMATCH and MATCH strings are? Something like:
Code:
$seq = "XX**XXX!!!X**AB*!C*DXX*!!!XXX**XXX";
$seq =~ /A[!*]*B[!*]*C[!*]*D/;
$to = length($&) - 1 + ($from = length($'));
print "from $from to $to\n";
grahame is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
confused , strings


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
cutting strings alexgeek PHP 5 August 29th, 2007 01:12 PM
Query Strings and concat magnetica JavaScript 1 August 22nd, 2007 09:22 AM
Javascript Strings Help Sabin_33 JavaScript 2 December 21st, 2006 05:54 AM
Stripping Characters out of Strings ? itsmarkdavies JavaScript 3 August 23rd, 2006 04:35 PM
Quotes in strings jakyra Classic ASP 5 September 9th, 2003 11:10 AM


Search Engine Optimization by vBSEO 3.2.0 RC8