I want to search a regex in perl without replacing it and without going line by line to search it
Any help will be apriciable
Thanks in advance
7 1680 Icecrack 174
Recognized Expert New Member
Question:
What have your tried so far?
How can we work with what you want, if we do not know the information we are looking for?
Thanks
Charlie
KevinADC 4,059
Recognized Expert Specialist
You can't search a regexp, the question makes no sense. You can search a file or a database, but you can't search a regexp.
I have tried to serch each and every line in the file using - open FH,"log";
-
for $line(<FH>){
-
if( $line =~ m/regexp/ )
-
{
-
}
-
}
but i dont want to look each and every line in the file
Thanks
numberwhun 3,509
Recognized Expert Moderator Specialist @Vipul03
If you don't try and match against every line, how are you going to have a proper search? Inside of the if statement, if you don't do anything, like print the line or the line number, then you will never know that there was a match.
Regards,
Jeff
KevinADC 4,059
Recognized Expert Specialist
maybe this is what you want, hard to say because I guess you think we can read your mind and understand your vague question: -
open FH,"log";
-
while (my $line = <FH>){
-
if( $line =~ m/regexp/ ) {
-
"Found regexp in $line\n";
-
last; $stops searching after first match
-
}
-
}
-
close FH;
-
If thats not what you are trying to do then please explain yourself properly so other people can understand what your requirements are.
Icecrack 174
Recognized Expert New Member @KevinADC
I know in the quick making of that script you may of made a mistake or typo at KevinADC 4,059
Recognized Expert Specialist @Icecrack
Yes thanks, should have been "#stops searching" instead of "$stops Searching".
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: David Morgan |
last post by:
Hello
I have a little function to highlight text if it exists.
Function Highlight(vFind, vSearch)
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = vFind
RegEx.IgnoreCase = True
Highlight = RegEx.Replace(vSearch, "<span class=""Highlight"">" & vFind &
|
by: Xah Lee |
last post by:
in the regex module re:
Note: Match() is not exactly equivalent to Search() with "^". For
example:
re.search(r'^B', 'A\nB',re.M) # succeeds
re.match(r'B', 'A\nB',re.M) # fails
if without the re.M, would re.search and re.match be equivalent?
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if ((someString.IndexOf("something1",0) >= 0) ||
((someString.IndexOf("something2",0) >= 0) ||
|
by: clintonG |
last post by:
I'm using an .aspx tool I found at but as nice as the interface is I
think I need to consider using others. Some can generate C# I understand.
Your preferences please...
<%= Clinton Gallagher
http://forta.com/books/0672325667/
|
by: Mike Hildner |
last post by:
I'm receiving bytes over a socket and displaying in a text box. In the
responses I receive, some lines are delimited with x0A and others with
x0D0A. I'd like to search for x0A and replace with x0D0A, but only if x0A is
preceeded with x0D - so I don't end up with x0D0D0A.
Right now I'm searching for x0D0A, replacing with x0A, then searching for
x0A and replacing with x0D0A. Seems a little ugly.
Is there a better way to do this? I...
| |
by: Craig Buchanan |
last post by:
Is there a way to combine these two Replace into a single line?
Regex.Replace(Subject, "\&", "&")
Regex.Replace(Subject, "\'", "'")
Perhaps Regex.Replace(Subject, "{\&|\'}", "{&|'}")
Thanks,
Craig
|
by: lucky |
last post by:
hi there!!
i'm looking for a code snipett wich help me to search some words into a
particular string and replace with a perticular word. i got a huge data
string in which searching traditional way mean to secrife lots of time
in asp.net. can any one give me such a expression in which i pass a
data string and search word string and replace word string? if so plz
help me out. i'm in badly need.
|
by: Martin Evans |
last post by:
Sorry, yet another REGEX question. I've been struggling with trying to get
a regular expression to do the following example in Python:
Search and replace all instances of "sleeping" with "dead".
This parrot is sleeping. Really, it is sleeping.
to
This parrot is dead. Really, it is dead.
|
by: Chris |
last post by:
Hi Everyone,
I am using a regex to check for a string. When all the file contains is my
test string the regex returns a match, but when I embed the test string in
the middle of a text file a match is never returned.
The string that I give to the regex is one that contains the entire contents
of a text file.
I'm using the multi-line option and I've also tried stripping out the VbCr
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |