Click here to Skip to main content
14,668,357 members
Home » Discussions » Regular Expressions
   

Regular Expressions

 
QuestionRegEx: Get Values from HTML Attribute Tags Pin
Member 1046475230-Sep-20 19:47
MemberMember 1046475230-Sep-20 19:47 
AnswerRe: RegEx: Get Values from HTML Attribute Tags Pin
Richard MacCutchan30-Sep-20 21:26
mveRichard MacCutchan30-Sep-20 21:26 
AnswerRe: RegEx: Get Values from HTML Attribute Tags Pin
Richard Deeming30-Sep-20 22:14
mveRichard Deeming30-Sep-20 22:14 
GeneralRe: RegEx: Get Values from HTML Attribute Tags Pin
Member 104647521-Oct-20 3:58
MemberMember 104647521-Oct-20 3:58 
GeneralRe: RegEx: Get Values from HTML Attribute Tags Pin
Dave Kreskowiak1-Oct-20 4:41
mveDave Kreskowiak1-Oct-20 4:41 
GeneralRe: RegEx: Get Values from HTML Attribute Tags Pin
Richard Deeming1-Oct-20 4:41
mveRichard Deeming1-Oct-20 4:41 
QuestionString Replacement Pin
Michael Eckstein19-Sep-20 20:27
MemberMichael Eckstein19-Sep-20 20:27 
AnswerRe: String Replacement Pin
Richard MacCutchan19-Sep-20 21:11
mveRichard MacCutchan19-Sep-20 21:11 
GeneralRe: String Replacement Pin
Michael Eckstein19-Sep-20 22:28
MemberMichael Eckstein19-Sep-20 22:28 
GeneralRe: String Replacement Pin
Michael Eckstein20-Sep-20 0:19
MemberMichael Eckstein20-Sep-20 0:19 
GeneralRe: String Replacement Pin
Michael Eckstein20-Sep-20 1:01
MemberMichael Eckstein20-Sep-20 1:01 
GeneralRe: String Replacement Pin
Richard MacCutchan20-Sep-20 1:32
mveRichard MacCutchan20-Sep-20 1:32 
QuestionRegEx Split Pin
Member 148774747-Sep-20 7:56
MemberMember 148774747-Sep-20 7:56 
Hi
I have a line in my csv file as below

""|*"I have delimiter |* and an escaped \" quote  in me"|*100|*200|*300|*"am a string"|*""


I have to interpret " quote as text-qualifier and |* as delimiter. I have to ignore escaped quote \" and consider it part of the string. 100, 200, 300 are integer data fields, so, they are not surrounded by text-qualifier.

The expected result is an array of strings.

a[0] = "" which is a Null string
a[1] = "I have delimiter |* and an escaped \" quote in me"
a[2] = "100"
a[3] = "200"
a[4] = "300"
a[5] = "am a string"
a[6] = "" which is a Null string

Code is as below, it looks like \" is not getting escaped properly, could you please let me know how to fix this, thanks.

The RegularExpression code is as in here: Split Function that Supports Text Qualifiers[^]

using System.Text.RegularExpressions;

public string[] Split(string expression, string delimiter, 
			string qualifier, bool ignoreCase)
{
    string _Statement = String.Format
		("{0}(?=(?:[^{1}]*{1}[^{1}]*{1})*(?![^{1}]*{1}))", 
                        Regex.Escape(delimiter), Regex.Escape(qualifier));

    RegexOptions _Options = RegexOptions.Compiled | RegexOptions.Multiline;
    if (ignoreCase) _Options = _Options | RegexOptions.IgnoreCase;

    Regex _Expression = New Regex(_Statement, _Options);
    return _Expression.Split(expression);
}

AnswerRe: RegEx Split Pin
Richard Deeming7-Sep-20 22:43
mveRichard Deeming7-Sep-20 22:43 
Question9 million Rows in Excel Pin
IzaacSpyro30-Aug-20 22:20
MemberIzaacSpyro30-Aug-20 22:20 
QuestionFinding a specific number in a string. Pin
Member 1086910714-Aug-20 11:36
MemberMember 1086910714-Aug-20 11:36 
AnswerRe: Finding a specific number in a string. Pin
Richard MacCutchan14-Aug-20 21:40
mveRichard MacCutchan14-Aug-20 21:40 
GeneralRe: Finding a specific number in a string. Pin
Member 1086910715-Aug-20 1:17
MemberMember 1086910715-Aug-20 1:17 
QuestionHow to skip a particular term in regex find and replace? Pin
usernamekiran11-Aug-20 4:34
Memberusernamekiran11-Aug-20 4:34 
AnswerRe: How to skip a particular term in regex find and replace? Pin
Gerry Schmitz11-Aug-20 6:39
mveGerry Schmitz11-Aug-20 6:39 
QuestionFind Sequence of alphabets in the string Pin
arisaravanan11-Apr-20 1:32
Memberarisaravanan11-Apr-20 1:32 
AnswerRe: Find Sequence of alphabets in the string Pin
Richard MacCutchan11-Apr-20 4:21
mveRichard MacCutchan11-Apr-20 4:21 
AnswerRe: Find Sequence of alphabets in the string Pin
Richard Deeming14-Apr-20 0:30
mveRichard Deeming14-Apr-20 0:30 
QuestionUsing A Regular Expression To Show Rows In Pandas (Python) Pin
Eddie Winch2-Feb-20 9:05
MemberEddie Winch2-Feb-20 9:05 
QuestionTSV out of a tab-based tree-like file Pin
DynV9-Nov-19 19:43
MemberDynV9-Nov-19 19:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.