1

I want Regex to start at the first word/number that isn't blank. In my example below, I want to start at LG. There are lots of other lines of a near identical structure I will also have to match through.

    <div class="p13n-sc-truncate p13n-sc-truncated-hyphen p13n-sc-line-clamp-2" aria-hidden="true" data-rows="2" data-truncate-mix-weblab='true'>

        LG 32MA68HY-P 32-Inch IPS Monitor with Display Port and HDMI Inputs

My Regex is.. (?<='True'>\n).*.(?=\n)

Rather than adding a lot of dots is there a way to start at the first letter/number/word for this line?

I believe [^\s] should work but I can't get it working..

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • Could you please explain what you mean by *start*? Match a line omitting the leading whitespace? You may use `\S.*`. Or, `^\h*\K.*`. – Wiktor Stribiżew Jul 16 '17 at 09:04
  • @WiktorStribiżew Yes when I say start I mean ommitting the white space and starting at in this case LG. Something like (?<='True'>\n.\S.*).*.(?=\n). I'll try it out.. –  Jul 16 '17 at 09:10
  • @WiktorStribiżew Hmm doesn't seem to work. It's very stubborn. Are you able to get LG 32MA68HY-P 32-Inch IPS Monitor with Display Port and HDMI Inputs with no white space at the front? I can trim through another proecess later but ideally I would of thought this can be done in Regex without that extra step –  Jul 16 '17 at 09:13
  • Maybe [like this](https://regex101.com/r/IrxDm8/2). – Wiktor Stribiżew Jul 16 '17 at 09:16
  • @WiktorStribiżew I'm using editpadpro atm I'll see if I can't modify that and get it working. –  Jul 16 '17 at 09:21
  • @WiktorStribiżew \k appears to come up as an error when I use that. It works on that site but not in editpadpro or when I run the job –  Jul 16 '17 at 09:25
  • @WiktorStribiżew BEAU-TIFUL. Thanks dude! I modified my code incorporating what you did. (?<='true'>\n\s+)\w.*.*(?=\n\s+) –  Jul 16 '17 at 09:49
  • Looks like in EditPadPro infinite width lookbehind is available. – Wiktor Stribiżew Jul 16 '17 at 15:58

1 Answers1

0

EditPadPro from JG Software is powered with a regex engine that supports infinite width lookbehind.

You may use a positive lookbehind that makes sure there is a 'true'> substring followed with a newline and 0+ whitespaces immediately to the left of the current location. Then, you may just consome a non-whitespace char followed with any 0+ chars other than newline.

Here is an example:

(?<='true'>\r?\n\s*)\S.*

See the regex demo

If the char should be a word char, replace \S with \w.

Details:

  • (?<='true'>\r?\n\s*) - a positive lookbehind that makes sure there is a 'true'> substring followed with an optional CR and then an LF and 0+ whitespaces immediately to the left of the current location
  • \S - any non-whitespace char
  • .* - any 0+ chars other than newline as many as possible.
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563