hi,
I need some help with a reg. expression. I have a comma delimited file with
quotes. Not every field has quotes, only some. This is a sample of my file:
99,"01/01/2007","23,000",1,34,"henry",132,"45.00"
I used some code from an article that I though would do what I needed, but
it splits my amount fields(76,000 into two different fields : 76, and 000...
Do I change my pattern ? I never used regex before and need some help. thank
you. -
Dim re As Object = SplitAdv(sr.ReadToEnd)
-
-
Function SplitAdv(ByVal strInput)
-
Dim objRE
-
Dim pattern As String
-
pattern = ",(?=([^']*'[^']*')*(?![^']*'))"
-
objRE = New Regex(pattern)
-
' .Replace replaces the comma that we will use with
-
' chr(8), the \b character which is extremely unlikely
-
' to appear in any string it then splits the line into
-
' an array based on the \b
-
'Console.WriteLine(objRE.ToString)
-
SplitAdv = Split(objRE.Replace(strInput, "\b"), "\b")
-
-
End Function
-
4 1248
Hi,
I think I found a better pattern, but I can't seem to get it defined
correctly in a string
I have this:
pattern = "((?:[^',]|(?:'(?:\\{2}|'|[^'])*?'))*)"
I would like to change the single quotes to double quotes, but it doesnt
like what I'm doing. I tried putting escape characters before the " like so:
\", but it does not like it. How in the world can I do this? I've spent about
2 hours on this alone and am stuck. Please advise. Thanks!
"maggie" wrote:
hi,
I need some help with a reg. expression. I have a comma delimited file with
quotes. Not every field has quotes, only some. This is a sample of my file:
99,"01/01/2007","23,000",1,34,"henry",132,"45.00"
I used some code from an article that I though would do what I needed, but
it splits my amount fields(76,000 into two different fields : 76, and 000...
Do I change my pattern ? I never used regex before and need some help. thank
you. -
Dim re As Object = SplitAdv(sr.ReadToEnd)
-
Function SplitAdv(ByVal strInput)
-
Dim objRE
-
Dim pattern As String
-
pattern = ",(?=([^']*'[^']*')*(?![^']*'))"
-
objRE = New Regex(pattern)
-
' .Replace replaces the comma that we will use with
-
' chr(8), the \b character which is extremely unlikely
-
' to appear in any string it then splits the line into
-
' an array based on the \b
-
'Console.WriteLine(objRE.ToString)
-
SplitAdv = Split(objRE.Replace(strInput, "\b"), "\b")
-
End Function
-
You might find Expresso useful ( http://www.ultrapico.com/).
Since I already have a headache from my own regex mystery today I did not
try to understand your pattern, and I have never used the Regex Split
method. But I did play around with your basic problem and came up with the
following pattern
((?<q>"?)[/,\w\d\.]+\k<q>,?)
which yields this result
99,
"01/01/2007",
"23,000",
1,34,
"henry",
132,
"45.00"
when fed your sample data. IF that's what you want, and IF you don't need
to use the Split method.
Good Luck, Bob
"maggie" <ma****@discussions.microsoft.comwrote in message
news:25**********************************@microsof t.com...
hi,
I need some help with a reg. expression. I have a comma delimited file
with
quotes. Not every field has quotes, only some. This is a sample of my
file:
99,"01/01/2007","23,000",1,34,"henry",132,"45.00"
I used some code from an article that I though would do what I needed, but
it splits my amount fields(76,000 into two different fields : 76, and
000...
Do I change my pattern ? I never used regex before and need some help.
thank
you. -
Dim re As Object = SplitAdv(sr.ReadToEnd)
-
Function SplitAdv(ByVal strInput)
-
Dim objRE
-
Dim pattern As String
-
pattern = ",(?=([^']*'[^']*')*(?![^']*'))"
-
objRE = New Regex(pattern)
-
' .Replace replaces the comma that we will use with
-
' chr(8), the \b character which is extremely unlikely
-
' to appear in any string it then splits the line into
-
' an array based on the \b
-
'Console.WriteLine(objRE.ToString)
-
SplitAdv = Split(objRE.Replace(strInput, "\b"), "\b")
-
End Function
-
I ,too,have a big headache, but you helped. I'm going to try it. Thanks very
much.
"eBob.com" wrote:
You might find Expresso useful (http://www.ultrapico.com/).
Since I already have a headache from my own regex mystery today I did not
try to understand your pattern, and I have never used the Regex Split
method. But I did play around with your basic problem and came up with the
following pattern
((?<q>"?)[/,\w\d\.]+\k<q>,?)
which yields this result
99,
"01/01/2007",
"23,000",
1,34,
"henry",
132,
"45.00"
when fed your sample data. IF that's what you want, and IF you don't need
to use the Split method.
Good Luck, Bob
"maggie" <ma****@discussions.microsoft.comwrote in message
news:25**********************************@microsof t.com...
hi,
I need some help with a reg. expression. I have a comma delimited file
with
quotes. Not every field has quotes, only some. This is a sample of my
file:
99,"01/01/2007","23,000",1,34,"henry",132,"45.00"
I used some code from an article that I though would do what I needed, but
it splits my amount fields(76,000 into two different fields : 76, and
000...
Do I change my pattern ? I never used regex before and need some help.
thank
you. -
Dim re As Object = SplitAdv(sr.ReadToEnd)
-
-
Function SplitAdv(ByVal strInput)
-
Dim objRE
-
Dim pattern As String
-
pattern = ",(?=([^']*'[^']*')*(?![^']*'))"
-
objRE = New Regex(pattern)
-
' .Replace replaces the comma that we will use with
-
' chr(8), the \b character which is extremely unlikely
-
' to appear in any string it then splits the line into
-
' an array based on the \b
-
'Console.WriteLine(objRE.ToString)
-
SplitAdv = Split(objRE.Replace(strInput, "\b"), "\b")
-
-
End Function
-
eBob,
The dollar amounts came out on their own, but I still have some all strung
together with commas, which is better than what I had. I'll see if i can
separate them. Thanks again.
"eBob.com" wrote:
You might find Expresso useful (http://www.ultrapico.com/).
Since I already have a headache from my own regex mystery today I did not
try to understand your pattern, and I have never used the Regex Split
method. But I did play around with your basic problem and came up with the
following pattern
((?<q>"?)[/,\w\d\.]+\k<q>,?)
which yields this result
99,
"01/01/2007",
"23,000",
1,34,
"henry",
132,
"45.00"
when fed your sample data. IF that's what you want, and IF you don't need
to use the Split method.
Good Luck, Bob
"maggie" <ma****@discussions.microsoft.comwrote in message
news:25**********************************@microsof t.com...
hi,
I need some help with a reg. expression. I have a comma delimited file
with
quotes. Not every field has quotes, only some. This is a sample of my
file:
99,"01/01/2007","23,000",1,34,"henry",132,"45.00"
I used some code from an article that I though would do what I needed, but
it splits my amount fields(76,000 into two different fields : 76, and
000...
Do I change my pattern ? I never used regex before and need some help.
thank
you. -
Dim re As Object = SplitAdv(sr.ReadToEnd)
-
-
Function SplitAdv(ByVal strInput)
-
Dim objRE
-
Dim pattern As String
-
pattern = ",(?=([^']*'[^']*')*(?![^']*'))"
-
objRE = New Regex(pattern)
-
' .Replace replaces the comma that we will use with
-
' chr(8), the \b character which is extremely unlikely
-
' to appear in any string it then splits the line into
-
' an array based on the \b
-
'Console.WriteLine(objRE.ToString)
-
SplitAdv = Split(objRE.Replace(strInput, "\b"), "\b")
-
-
End Function
-
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tony C |
last post by:
I'm writing a python program which uses regular expressions, but I'm
totally new to regexps.
I've got Kuchling's "Regexp HOWTO", "Mastering Regular Expresions" by
Oreilly, and have access to...
|
by: Bibe |
last post by:
I've been trying to get this going for awhile now, and need help. I've
done a regex object, and when I use IsMatch, it's behavior is quite weird.
I am trying to use Regex to make sure that a...
|
by: H |
last post by:
This is kind of an followup on oneof my previous questions, and it has with
RegEx to do.
I have a string containing of several words. What would a good regex
expression looklike to get one match...
|
by: Dave |
last post by:
I'm struggling with something that should be fairly simple. I just don't
know the regext syntax very well, unfortunately.
I'd like to parse words out of what is basically a boolean search...
|
by: henrik |
last post by:
Hi
I have a regex question. I want to find all content of a <td
class="someclass"> tag. This means the expression should include all other
tags included between <td class="someclass"> and </td>....
|
by: jmchadha |
last post by:
I have got the following html:
"something in html ... etc.. city1... etc... <a class="font1"
href="city1.html" onclick="etc."click for <b>info</bon city1 </a>
... some html. city1.. can repeat...
|
by: Alex Maghen |
last post by:
This is a bit of an abuse of this group. Just a nit, but I'm hoping someone
really good with Regular Expressions can help me out here.
I need to write a regular expression that will do the...
|
by: =?Utf-8?B?TmF2ZWVu?= |
last post by:
Not sure if this is the right forum for this question but couldn'd find
another newsgroup.
I am new to Regular expressions and would like help in deciding which
pattern allows me to split a...
|
by: supercrossking |
last post by:
I am trying to the values of string of text in the sample before. The
ds are for digits and s is for string and string of text is for a
string with more than one or two values. I am trying to use...
|
by: Support Desk |
last post by:
That’s it exactly..thx
-----Original Message-----
From: Reedick, Andrew
Sent: Tuesday, June 03, 2008 9:26 AM
To: Support Desk
Subject: RE: regex help
The regex will now skip anything with...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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...
|
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...
| |