Problem capturing last group in a line: CLOSED
-
Don't know if this is the correct solution but it seems to work. Using the RegexOptions.RightToLeft option seems to work. I'm not too familiar with Regex. I've created an expression to capture data in a line and it works except for the last group DataType which does not extract the value "dtText". Can someone help? Thank You Expression: FieldName=(?.*?),ColumnWidth=(?.*?),Size=(?.*?),DataType=(?.*?) Data: FieldName=Field1,ColumnWidth=50,Size=10,DataType=dtText Output: FieldName: [Field1] ColumnWidth: [50] Size: [10] DataType []
-
Don't know if this is the correct solution but it seems to work. Using the RegexOptions.RightToLeft option seems to work. I'm not too familiar with Regex. I've created an expression to capture data in a line and it works except for the last group DataType which does not extract the value "dtText". Can someone help? Thank You Expression: FieldName=(?.*?),ColumnWidth=(?.*?),Size=(?.*?),DataType=(?.*?) Data: FieldName=Field1,ColumnWidth=50,Size=10,DataType=dtText Output: FieldName: [Field1] ColumnWidth: [50] Size: [10] DataType []
.*?
tells the expression to capture as little as possible. Since there's nothing to match after the last expression, the least it can capture is nothing, so that's precisely what it does. If you're looking to capture everything up to the end of the line, then you'll want to add an end-of-line anchor:...,DataType=(?<DataType>.*?)$
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
.*?
tells the expression to capture as little as possible. Since there's nothing to match after the last expression, the least it can capture is nothing, so that's precisely what it does. If you're looking to capture everything up to the end of the line, then you'll want to add an end-of-line anchor:...,DataType=(?<DataType>.*?)$
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer