regular expression in Csharp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    #1

    regular expression in Csharp

    Hi all,

    I have an if then statement to delete the following file in my computer,
    country=US!stat e=NY.txt

    let's say "country=US " is variable

    if (objFL.ToUpper( ).IndexOf(varia ble+"!",0)>=0

    {delete the file }

    But if there are some spaces between variable and ! (like file format
    below), then condition will fail as it can't find the match.

    country=US !state=NY.txt


    how do I use regular expression so I can do match "variable(space s or no
    spaces)!"








  • Alien

    #2
    Re: regular expression in Csharp

    try using this regex:

    ^country=[^ ].* {0,}!state=.*\. txt$

    "Mike" <pearl_77@hotma il.com> wrote in message
    news:e13wo1SVDH A.3972@tk2msftn gp13.phx.gbl...[color=blue]
    > Hi all,
    >
    > I have an if then statement to delete the following file in my computer,
    > country=US!stat e=NY.txt
    >
    > let's say "country=US " is variable
    >
    > if (objFL.ToUpper( ).IndexOf(varia ble+"!",0)>=0
    >
    > {delete the file }
    >
    > But if there are some spaces between variable and ! (like file format
    > below), then condition will fail as it can't find the match.
    >
    > country=US !state=NY.txt
    >
    >
    > how do I use regular expression so I can do match "variable(space s or no
    > spaces)!"
    >
    >
    >
    >
    >
    >
    >
    >[/color]


    Comment

    Working...