w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
RegEx/Python.findall() - Match something only if it appears before something else

This regex gets me the "last" STGN number before every IRV-occurrence, which I think is what you're asking for.

STGN:([0-9A-F]+)(?=(?:[^S]|S(?!TGN))*IRV)

Regular
expression visualization

Debuggex Demo

I don't understand how this relates to the names you wanna find but maybe this'll help you under way.

Brief notes:

  • [0-9A-F] finds hexadecimal numbers, which I think you're working with here
  • Basically this regex is saying "give me the STGN number followed by anything that isn't STGN and then IRV"




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.