Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > Regular Expressions, Help Me Pls

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-09-08, 02:10
srisha srisha is offline
Registered User
 
Join Date: Jan 2008
Location: India
Posts: 3
Regular Expressions, Help Me Pls

hi
I have small doubt. Hope u will clear that.
Usually in perl to count the occurance of a specific variable in the input we will use "count".
I want to know whether we can assign differnt variables and can be able to count the total no of that variables in the input...
EXAMPLE::

@m_sites = ( 'ggwxy', 'ggvtew', ' gyhtdj', hhhwqr' );

IF THE GIVEN INPUT SEQUENCE IS:
xxxxxxxggwxyxxxxxxxxxggwxyxxxxxxxxxxggvtewxxxxxxxxx

The output should be 3. Because the given patterns occured 3 times in the sequence.
i want to know what we can do to count the total no of m_sites in the input

Thanks in advance.

Last edited by srisha : 01-10-08 at 00:21.
Reply With Quote
  #2 (permalink)  
Old 01-14-08, 10:24
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Fort Polk, LA
Posts: 500
Since I can barely guess at what you're asking, I won't spend a lot of time explaining myself. Try this:

Code:
my $re = join('|', map(quotemeta, @m_sites)); print scalar($input =~ /$re/g);
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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