Search code examples
regexnegate

how do I match negative regex?


There is a sharepoint url :
http://teamspace.abc.com/sites/ABC/?list=%7bCEE6E6CB-A035-4FF9-Af95-98784D732938%7d

The listID could be various but I only want to allow the above one. Therefore, it shouldn't match:

http://teamspace.abc.com/sites/ABC/?list=%7bDEXXXXxxxx-A035-4FF9-Af95-98784D732938%7d url

Is there any way I can match only if url is the following: http://teamspace.abc.com/sites/ABC/?list=%7bCEE6E6CB-A035-4FF9-Af95-98784D732938%7d"


Solution

  • better use == operator (equals() in java and C#)

    String http = "http";
    String shp = "sharepoint";
    String url = "://teamspace.abc.com/sites/ABC/?list=%7bCEE6E6CB-A035-4FF9-Af95-98784D732938%7d";
    if(myUrl.equals(http+url) || myUrl.equals(shp+url))
    {
        //do what you want
    }
    example for java