hi, this is somewhat link to the other post i posted
but i shall put it in another topic for easy reference
previously i had -
/* 4 ABC:DEFG=12334556,BSERV=T22; */
-
i actualli used the regexp to match it -
foreach $data1 (@$data)
-
{
-
chomp ($data1);
-
if ($data1 =~ /4 \D\D\D:/){
-
print "$data1\n";
-
} }
-
but right how can i just get -
-
ABC:DEFG=12334556,BSERV=T22;
-
i tried using
didn't work..so i'm not too sure about the syntax
6 1918
Use: -
foreach $data1 (@$data)
-
{
-
chomp ($data1);
-
if ($data1 =~ /4 (\D\D\D:.+)\*/){
-
print "$1\n"; # $1 will hold the pattern inside parantheses
-
} }
-
The title of your post doesn't match your description. If you actually wanted to match begining and end of a line, here is how to do it.
The symbol '^' will denote beginning of line/string inside pattern match. For ex:
/^The/ will match only the lines begining with 'The'.
Similarly, the symbol '$' will denote end of line/string inside pattern match. For ex:
/end$/ will match only the lines ending with 'end'.
hm...thanks nithinpes
i might need the code for beginning and end of statements
i guess for this case it should somehow be match a part of a sentence ending with special characters like "*", "%", and stuff
anyway if i use ".*" it matches 1 character 0 or more times right?
and ".+" it matches 1 character 1 or more times right?
hm...thanks nithinpes
i might need the code for beginning and end of statements
i guess for this case it should somehow be match a part of a sentence ending with special characters like "*", "%", and stuff
anyway if i use ".*" it matches 1 character 0 or more times right?
and ".+" it matches 1 character 1 or more times right?
Yes. That's right!
One way of matching special characters is to escape them(using '\'). For example in your text, if you wanted to match lines with '/* 4' you could use, -
if ($data1 =~ /\/\* 4/) {
-
Also, you could use \Q and \E. \Q will remove any special meaning, inside pattern match, of the characters that follow it upto \E.
For ex: -
if ($data1 =~ /\Q/* @+/\E/) { # will match '/* @+/'
-
if ($data1 =~ /\Q/* ...\E.+/) {# will match '/* ...' followed by one/more characters
-
I would suggest you to go through this: Perl RE
-Nithin
alright
thanks you very much nithin
was looking for some reference too
thanks!
cheers, :)
hey guys another question to ponder about
how long u think it takes to do a search on my code below
roughly around 2,375 KB of data -
foreach $data1 (@data)
-
{
-
chomp ($data1);
-
-
if ($data1 =~ /3 SESSION/ && $data1 !~ /2 TBHLR/ && $data1 !~ /1 TBHLR/ && $data1 !~ /4c COMMAND/ && $data1 !~ /4c
-
SESSION/){
-
-
my $user_line = index ($data1, "3 SESSION");
-
my $user = substr ($data1, ($user_line+23),6);
-
push @array1,$user;
-
-
my $time_line = index ($data1, "USERID");
-
my $time = substr ($data1, ($time_line+25),8);
-
push @array2,"$time\n";
-
-
push @array3, "$date\n";
-
-
}elsif
-
($data1 =~ /4 (\D\D\D:.+)\*/){
-
push @array4, "$1\n";
-
-
}}
-
and all these datas are added into MySQL database
i time it and ard 5-6 mins
u think it's already considered fast?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: redryderridesagain |
last post by:
Using the Microsoft VBScript Regular Expressions 5.5 library in
MS-Access VBA 6.3.
I understand why the code below finds an occurance of the string "PC:
blah blah blah A: BBB aaa B: BBB bbb C:...
|
by: TokyoJ |
last post by:
I run a small camp in Alaska for kids and my director is asking for a web form. Could someone please have a look and offer some advice on where I'm making mistake(s)?
I'm using the RegExp function...
|
by: s99999999s2003 |
last post by:
hi
how can i use regexp to group these digits into groups of 3?
eg
line 123456789123456789
i have :
pat = re.compile("line\s+(\d{3})" , re.M|re.DOTALL)
|
by: Papkin |
last post by:
Hi
if ( eregi("^/a-zA-Z0-9±ęćłń󶿼ˇĆĘŁŃÓ¦¬Ż\.\/\/-]{2,65}$","Merry
& Cat") )
return true;
else
return false;
I'd like to match also "&" but this regexp above does not do...
|
by: richardkreidl |
last post by:
I have the following string below in which I need to pull out the name
that follows: ContactsManager:" .
In this particular case it would be:
BARBARA JOSEPH
Job Completion, Failure...
|
by: Ciaran |
last post by:
Hi can someone give me hand with this please?
What's the best way to extract the extension from the url?
example:
$string="http://www.domain.co.uk/anypage.html"
In this example, I'd be...
|
by: TobbeK |
last post by:
Anyone having experience in MySQL and REGEXP ?
I have 1 input field, "what"
Let's say I have the input value "e-mail" and the database field contains the value "email". Is there some way to put...
|
by: poolboi |
last post by:
hey guys,
another regexp problem which i'm probably not good at here goes
my text file has this
/* 1 TB VTP-1 SESSION=01547 USERID STARTED 2008-05-13 09:46:11 */
I AM A GIRL
/* 3...
|
by: Velhari |
last post by:
Hi all,
I wrote the following Javascript function used to execute the Javascript codes from the ajax response which contains both html & javascript.
It works fine, if the javascript codes from...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
| |