Search code examples
powershellnumberssymbols

Finding "? and number behind it"


I've this little script

Select-String -Path XXX\*.VML, XXX\*.STA -pattern "\?[a-z]", "\?[\,, \., \ , \!, \?, \*, \+, \-, \(, \)]", "\?_"

And I need to add pattern to look up for "?1" , "?2", etc.. from 0 - 9, can you help me please?


Solution

  • \d is for "digit", so:

    Select-String ... -Pattern '\?\d(?!>\d)'
    

    The negative lookahead at the end ((?!>\d)) will ensure it's not followed by another digit, so it'll match ?1 and ?2 but not ?12