Click here to Skip to main content
14,925,899 members
Home / Discussions / Regular Expressions
   

Regular Expressions

 
GeneralRe: Regular Expression to Change Uppercase Text to Lowercase Pin
Member 1357268425-Dec-20 8:41
MemberMember 1357268425-Dec-20 8:41 
AnswerRe: Regular Expression to Change Uppercase Text to Lowercase Pin
Gerry Schmitz24-Dec-20 4:57
mveGerry Schmitz24-Dec-20 4:57 
GeneralRe: Regular Expression to Change Uppercase Text to Lowercase Pin
Member 1357268424-Dec-20 5:14
MemberMember 1357268424-Dec-20 5:14 
QuestionCapture values using regex Pin
akwillows8-Dec-20 6:22
Memberakwillows8-Dec-20 6:22 
AnswerRe: Capture values using regex Pin
Richard Deeming8-Dec-20 6:35
mveRichard Deeming8-Dec-20 6:35 
GeneralRe: Capture values using regex Pin
akwillows8-Dec-20 6:37
Memberakwillows8-Dec-20 6:37 
GeneralRe: Capture values using regex Pin
Richard Deeming8-Dec-20 21:39
mveRichard Deeming8-Dec-20 21:39 
QuestionA Regular Expression that will search and replace characters from a string Pin
Member 135726842-Dec-20 9:05
MemberMember 135726842-Dec-20 9:05 
AnswerRe: A Regular Expression that will search and replace characters from a string Pin
Richard Deeming2-Dec-20 22:23
mveRichard Deeming2-Dec-20 22:23 
GeneralRe: A Regular Expression that will search and replace characters from a string Pin
Member 135726843-Dec-20 0:52
MemberMember 135726843-Dec-20 0:52 
AnswerRe: A Regular Expression that will search and replace characters from a string Pin
GenJerDan3-Dec-20 1:38
MemberGenJerDan3-Dec-20 1:38 
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 

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.