How to use regex to find exact match of a word but ignoring the same text with preposition? C# -


Hello I am working with DXF files and I have got some problems for regular expressions.

123 abc GR-body attrib acdbline

And I have written some regular expression that should be working but clearly still this regular Expression requires some help

Here is my code

  string [] tmp = Regex.Split (original string, @ "(3DFACE | 3DSOLID | A CAD_PROXY_ENTITIY | ARC | ATTDEF | ATTRIB | Body | Circle | Dimensions | Ellipse | Hatch | HELIX | Insert image | | Leader | Lighting | LWPOLYLINE | MLINE | MLEADERSTYLE | MLEADER | MTEXT | OLEFRAME | OLE2FRAME | point | polyline | Ray | Area | SEQEND | size | solid | Splain | Sin | Surfe | table | text | TOLERANCE | TRACE | Anderle | VERTEX | VIEWPORT | WIPEOUT | XLINE | LINE) ", Regeksowshans. a);   

And I just want to capture the text of the body but GR-body is still included, how to take out the GR-body? Thanks

1 Edit I'm sorry that I first search for the wrong code

umm I want to output like this

  tmp [0] = body TMP [1] = 123 \ nabc \ nGR-LINE \ nattrib \ nAcdbLine   

because my code was only able to do it like this

  TMP [0] = Body TMP [1] = 123 \ nabc \ nGR-TMP [2] = body \ nTribb \ nCCDBline    

This regex statement should work. Instead, try using Regex.Matches to return MatchCollection .

  Match Collection MC = Regex.Matches (original string, @ "(3DFACE | 3DSOLID | ACAD_PROXY_ENTITIY | ARC | ATTDEF | ATTRIB | Body | Circle | Dimensions | Ellipse | Hatch | HELIX | image | insert | leader | Lighting | LWPOLYLINE | MLINE | MLEADERSTYLE | MLEADER | MTEXT | OLEFRAME | OLE2FRAME | point | polyline | ray | area | SEQEND | size | solid | Splain | SUN | Surfa | table | text | TOLERANCE | TRACE | UNDERLAY | VERTEX | VIEWPORT | WIPEOUT | XLINE | LINE] ", ReggaeOption NO.); String [] tmp = mc.Cast & lt; Match & gt; () Select (M = & gt; m.Value) .Oir ();    

Comments