Regular expression - starting and not ending with a pattern

Cannon

How do I put a regular expression to check if a string starts with certain pattern and is NOT ending with certain pattern.

Example:

Must StartsWith: "US.INR.USD.CONV"
Should not end with: ".VALUE"

Passes Regex: "US.INR.USD.CONV.ABC.DEF.FACTOR"
Fails Regex Check: "US.INR.USD.CONV.ABC.DEF.VALUE"

I am using C#.

anubhava

You can use this regex based on negative lookahead:

^US\.INR\.USD\.CONV(?!.*?\.VALUE$).*$

RegEx Demo

Explanation:

  • ^US\.INR\.USD\.CONV - Match US.INR.USD.CONV at start of input
  • (?!.*?\.VALUE$) - Negative lookahead to make sure line is not ending with .value

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Regular expression - starting and not ending with a pattern

From Dev

Regular expression - Starting/ending with something specific and repeating pattern inbetween

From Java

Regular expression - starting and ending with a character string

From Dev

Regular Expression starting and ending with special characters

From Dev

Regular Expression To Match String Not Starting With Or Ending With Spaces

From Dev

Regular Expression starting and ending with special characters

From Dev

Regular Expression to check starting and ending of a email id to check bounced users

From Dev

Regular Expression to match lines not starting with [ and not ending with ] (ini headers)

From Dev

Regular Expression to match lines not starting with [ and not ending with ] (ini headers)

From Dev

How to extract lines between a starting and ending regular expression in Perl

From Dev

regular expression ending

From Dev

Regular expression to delete a word starting with sample_[some number] and ending with comma

From Dev

Regular Expression Group not ending with a string

From Dev

Search in vim for string starting and ending with a pattern

From Dev

Regular Expression for the Pattern?

From Dev

Regular Expression pattern issue

From Dev

Perl Regular Expression Pattern

From Dev

regular expression repeating pattern

From Dev

Javascript regular expression pattern

From Dev

String pattern, regular expression

From Dev

Regular expression to validate the pattern

From Dev

sawmill Regular expression pattern

From Dev

Custom regular expression pattern

From Dev

regular expression and pattern matching

From Dev

Regular expression not matching pattern

From Dev

Regular Expression to match pattern

From Dev

Define Regular Expression to match ending of URL

From Dev

Regular Expression for Matching String not beginning or ending with alphabet

From Dev

why do we put / and / in starting and ending of regular expressions in languages such as javascript?

Related Related

  1. 1

    Regular expression - starting and not ending with a pattern

  2. 2

    Regular expression - Starting/ending with something specific and repeating pattern inbetween

  3. 3

    Regular expression - starting and ending with a character string

  4. 4

    Regular Expression starting and ending with special characters

  5. 5

    Regular Expression To Match String Not Starting With Or Ending With Spaces

  6. 6

    Regular Expression starting and ending with special characters

  7. 7

    Regular Expression to check starting and ending of a email id to check bounced users

  8. 8

    Regular Expression to match lines not starting with [ and not ending with ] (ini headers)

  9. 9

    Regular Expression to match lines not starting with [ and not ending with ] (ini headers)

  10. 10

    How to extract lines between a starting and ending regular expression in Perl

  11. 11

    regular expression ending

  12. 12

    Regular expression to delete a word starting with sample_[some number] and ending with comma

  13. 13

    Regular Expression Group not ending with a string

  14. 14

    Search in vim for string starting and ending with a pattern

  15. 15

    Regular Expression for the Pattern?

  16. 16

    Regular Expression pattern issue

  17. 17

    Perl Regular Expression Pattern

  18. 18

    regular expression repeating pattern

  19. 19

    Javascript regular expression pattern

  20. 20

    String pattern, regular expression

  21. 21

    Regular expression to validate the pattern

  22. 22

    sawmill Regular expression pattern

  23. 23

    Custom regular expression pattern

  24. 24

    regular expression and pattern matching

  25. 25

    Regular expression not matching pattern

  26. 26

    Regular Expression to match pattern

  27. 27

    Define Regular Expression to match ending of URL

  28. 28

    Regular Expression for Matching String not beginning or ending with alphabet

  29. 29

    why do we put / and / in starting and ending of regular expressions in languages such as javascript?

HotTag

Archive