Hi,
Is there a way to find a line in a text file that starts with a forward slash? This is how i find a line in text file that starts with a word and then print that line to another text file: - open( FILE, "<$file" );
-
open( COPIED_FILE, ">$copiedfile" );
-
-
while( <FILE> )
-
{
-
$templine = $_;
-
if ($templine =~ m/DELTA\//)
-
{print COPIED_FILE "$templine";}
-
}
-
-
close FILE;
-
close COPIED_FILE;
But what if the line I'm trying to find starts with a forward slash...for example /DELTA? The thing is, i won't know everytime what word or number will be after the forward slash...
Thanks,
Terra
2 12641 numberwhun 3,509
Recognized Expert Moderator Specialist
Hi,
Is there a way to find a line in a text file that starts with a forward slash? This is how i find a line in text file that starts with a word and then print that line to another text file: - open( FILE, "<$file" );
-
open( COPIED_FILE, ">$copiedfile" );
-
-
while( <FILE> )
-
{
-
$templine = $_;
-
if ($templine =~ m/DELTA\//)
-
{print COPIED_FILE "$templine";}
-
}
-
-
close FILE;
-
close COPIED_FILE;
But what if the line I'm trying to find starts with a forward slash...for example /DELTA? The thing is, i won't know everytime what word or number will be after the forward slash...
Thanks,
Terra
Sure, you could use:
as your pattern match and put whatever you want to match after the \/ (that's backslash, forward slash. The backslash escapes the special meaning of the forward slash, as it does with other special characters inside of a regex.
Regards,
Jeff
Sure, you could use:
as your pattern match and put whatever you want to match after the \/ (that's backslash, forward slash. The backslash escapes the special meaning of the forward slash, as it does with other special characters inside of a regex.
Regards,
Jeff
Thank you so much!! That did it!
Terra
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Stephen Ferg |
last post by:
I have a question that is not directly Python-related. But I thought
I'd ask the most erudite group that I know... :-)
When did Windows start accepting the forward slash as a path separator
character?
At one time, it was accepted as a truism that Windows (like MS-DOS)
was different from Unix because Windows used the backslash as the path
separator character, whereas Unix used the forward slash.
|
by: Bruce |
last post by:
Hi -
I've been looking all over for this and found everything but the
variation I need. I have a one-row HTML table with a page title, as
text, with a specified font and size (not style).
example:
<table... border=0>
<tr>
|
by: Zanna |
last post by:
Hi all!
I'm in difficulty with this: I need to know the height of a text line that
is written with Graphics.DrawString().
In theory I need just to get the Graphics.MeasureString() result.
But this works if the string is on a single line.
If the string goes on more lines (caused by a new line or word wrap), it
seems that I need to compute the space between the lines, since the height
|
by: clintonG |
last post by:
I only ask this here because it so happens that Windows Search requires
filters to enable it to be used to find text in file types such as .aspx,
..cs and so on and is supposed to support doing so but does not. The KB
document explains the missing filters were supposed to be present after
applying the service packs but this has not proven true for any of the three
XP Pro machines with either SP1 or SP2 we have tested on this week.
Does...
|
by: Greg Collins [Microsoft MVP] |
last post by:
In reviewing my web site statistics, I see that I get 404 errors (often enough to make me ask about it) when users try to click on a link to a secure external site (i.e. an https:// link).
I've tested these links multiple times, and they always work fine for me. Other links do not seem to have trouble. It seems to be related to "https://" for some reason. I get this for another site too.
The statistics page shows the 404 failed link with...
| |
by: Kberg |
last post by:
In case anyone is interested, this is how I solved the problem of
replacing a back slash with a forward slash (as in being able to access
a document on a file share on an intranet via a browser)
if you cut and paste a path from windows explorer
\\myshare\mydir\mydoc.txt into a form textbox, you can use the
following code to transform it into something usable by a browser:
mytxt = document.myForm.myTextBox.value;
mytxt =...
|
by: sajithkahawatta |
last post by:
i am new to asp.
i want this,it should possible to copy text line from somewhere (like word doc with text format).and paste it on the asp page(in a text area or somewhere).
then code to get it from asp page and print in another asp page with its original text format .
if text area is not good what should i use to get a text line with it's format.
|
by: destroooooy |
last post by:
Hi folks,
I'm finding some (what I consider) curious behavior with the string
methods and the forward slash character. I'm writing a program to
rename mp3 files based on their id3 tags, and I want to protect
against goofy characters in the in tags. So I do the following:
unsafe_chars = "/#()!@$%^&*{}\'\"`?<>| \t\n"
alt_chars = "_________________________"
s_artist.translate(maketranstable(unsafe_chars, alt_chars))
|
by: Sevla |
last post by:
Hello,
i need to make a search of a text line on a dci/txt file and after i found it, i´d need to export this line to another new file.
could it be possible, copying a specific line of this dci/txt file and export it to a separated dci/txt file?
Thanks
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: 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...
| |