-1

I have these strings, and I'm looking to extract all characters after the first _. For example:

'hello _I _ am _ 123312'
'Nobody sa_dwdq casc_as _ 1233_12'
'_dosjadojs aod jao jdaso j'

The output expected:

' I _ am _ 123312'
'dwdq casc_as _ 1233_12'
'dosjadojs aod jao jdaso j'

This is the closest answer I found, but it's not in BigquerySQL language.

And this is what I have got so far, but it includes the matched character and I haven't found a way to not include the matched character through regex:

REGEXP_EXTRACT(str, r'_.*')
Mikhail Berlyant
  • 165,386
  • 8
  • 154
  • 230
Chris
  • 2,019
  • 5
  • 22
  • 67

2 Answers2

1

Use REGEXP_REPLACE instead to match what you don't want and delete that by replacing with blank:

REGEXP_REPLACE(str, r'^.*?_', '')
Bohemian
  • 412,405
  • 93
  • 575
  • 722
0

Here is one way to do it,

https://regex101.com/r/voPDE5/3

_(.*)
_ : Non Capturing group, matching exactly one occurrence of "_"  
(.*) : Captures the remainder of the string
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Naveed
  • 11,495
  • 2
  • 14
  • 21