How can I find the records which has last character "A" in notepad++

Viewed 84

I have huge JSON file in notepad++. One my field is product. I want to find out all the products which has character A in last in Value.

This is my data

{
    "ID": 689,
    "product": "GIPA",
    "JobID": 66349,
    "FriendlyName": "Android",
},
{
    "ID": 689,
    "product": "TKNA",
    "JobID": 66350,
    "FriendlyName": "Android",
},
{
    "ID": 689,
    "product": "TNRG",
    "JobID": 66351,
    "FriendlyName": "Android",
},
{
    "ID": 689,
    "product": "GAJT",
    "JobID": 66352,
    "FriendlyName": " Android",
},

I have tried two way but those are not working

"product": "^[a-z|A-Z|0-9]+[^A]\s?I{1}$"

And

"product": ".*(\A)$"

How can I find first two records?

1 Answers

Note the major issues with your regexps:

  • "product": "^[a-z|A-Z|0-9]+[^A]\s?I{1}$" contains ^ inside the pattern and thus it will never match as there is no start of string in the middle of it, where there is no pattern matching a line break before ^
  • [a-z|A-Z] matches letters AND also |, do not use | in character classes if you do not mean to match a literal | char (it loses its "alternation" meaning in between [...]
  • [^A] matches any char but A
  • {1} is always redundant, remove it. All patterns inside an expression are tried once by default.
  • "product": ".*(\A)$" contains \A, start of string anchor, which also invalidates the pattern, it will no longer match any string

You can use

"product": "[^"]*A"

It matches

  • "product": " - a literal string
  • [^"]* - 0 or more chars other than "
  • A" - A" string.
Related