473,378 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

regex brainfart

wow, i know this, but other than a good night sleep i feel like i' ve stumped myself...

after doing a regex i yield a line like...

/Archives/edgar/data/1304069/000002319407000064/0000023194-07-000064-index.htm">[htm

and I want just:
/Archives/edgar/data/1304069/000002319407000064/0000023194-07-000064-index.htm

any suggestions on how to get rid of that pesky ">[htm

Thanks
Sep 4 '07 #1
2 1064
ghostdog74
511 Expert 256MB
wow, i know this, but other than a good night sleep i feel like i' ve stumped myself...

after doing a regex i yield a line like...

/Archives/edgar/data/1304069/000002319407000064/0000023194-07-000064-index.htm">[htm

and I want just:
/Archives/edgar/data/1304069/000002319407000064/0000023194-07-000064-index.htm

any suggestions on how to get rid of that pesky ">[htm

Thanks
you should post your code, an a asample input file.
OTOH, to solve the problem that you stated, just use simple slicing
Expand|Select|Wrap|Line Numbers
  1. >>> s = """ /Archives/edgar/data/1304069/000002319407000064/0000023194-07-000064-index.htm">[htm"""
  2. >>> s[:-5]
  3. '/Archives/edgar/data/1304069/000002319407000064/0000023194-07-000064-index.htm"'
  4.  
  5.  
Sep 5 '07 #2
bartonc
6,596 Expert 4TB
wow, i know this, but other than a good night sleep i feel like i' ve stumped myself...

after doing a regex i yield a line like...

/Archives/edgar/data/1304069/000002319407000064/0000023194-07-000064-index.htm">[htm

and I want just:
/Archives/edgar/data/1304069/000002319407000064/0000023194-07-000064-index.htm

any suggestions on how to get rid of that pesky ">[htm

Thanks
The "non-greedy" dot-star:
Expand|Select|Wrap|Line Numbers
  1. >>> s = '/Archives/edgar/data/1304069/000002319407000064/0000023194-07-000064-index.htm">[htm'
  2. >>> import re
  3. >>> m = re.match('(/.*?htm)', s)
  4. >>> m.group(1)
  5. '/Archives/edgar/data/1304069/000002319407000064/0000023194-07-000064-index.htm'
  6. >>> 
Sep 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jon Maz | last post by:
Hi All, Am getting frustrated trying to port the following (pretty simple) function to CSharp. The problem is that I'm lousy at Regular Expressions.... //from...
9
by: Tim Conner | last post by:
Is there a way to write a faster function ? public static bool IsNumber( char Value ) { if (Regex.IsMatch( Value.ToString(), @"^+$" )) { return true; } else return false; }
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
17
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 ...
6
by: Extremest | last post by:
I have a huge regex setup going on. If I don't do each one by itself instead of all in one it won't work for. Also would like to know if there is a faster way tried to use string.replace with all...
7
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward...
3
by: aspineux | last post by:
My goal is to write a parser for these imaginary string from the SMTP protocol, regarding RFC 821 and 1869. I'm a little flexible with the BNF from these RFC :-) Any comment ? tests= def...
15
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
0
by: Karch | last post by:
I have these two methods that are chewing up a ton of CPU time in my application. Does anyone have any suggestions on how to optimize them or rewrite them without Regex? The most time-consuming...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.