News for hackers. Stuff that matters.
Re:Natural occurring molecule rivals Ozempic in weight loss,... by dleeftink on Friday March 07, 2025 @07:47AM (#43289727)
It's not that bad. AutoRegex[0] and regex gen [1] make it more accessible than ever.

[0]: https://www.autoregex.xyz/

[1]: https://regex-generator.olafneumann.org

Re:Natural occurring molecule rivals Ozempic in weight loss,... by janfoeh on Friday March 07, 2025 @08:20AM (#43289927)
Heh, I just fed autoregex a regex from one of my projects, and it simply times out. It comforts me to know that billion dollar LLMs have to chew on those just as much as I do.
Re:Natural occurring molecule rivals Ozempic in weight loss,... by dleeftink on Friday March 07, 2025 @09:36AM (#43290496)
A proper litmus test, what's causing the hang in your case?

Regex to me, is pattern finding and abstraction taken to the extreme. I like the challenge

Re:Natural occurring molecule rivals Ozempic in weight loss,... by tclancy on Friday March 07, 2025 @10:19AM (#43290851)
I think what's causing the hang is using the site. I gave it [a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12} and it sat thinking about things for a few minutes. So I tried the reverse and asked it "Match a UUID" and it sat and thought about things.

Now I am enlightened.

Re:Natural occurring molecule rivals Ozempic in weight loss,... by janfoeh on Friday March 07, 2025 @10:56AM (#43291202)
Aww shucks, and here I was feeling a wee bit proud of myself for managing to break it.
Re:Natural occurring molecule rivals Ozempic in weight loss,... by janfoeh on Friday March 07, 2025 @09:51AM (#43290629)
Good question. The regex I tried is for extracting amounts in EUR and USD:

  /
  (?<=^|[ \t])
  (?<currency_prefix_with_space>
    (?<currency_prefix>
      €|EUR|\$|USD
    )
    [ \t]?
  )?
  (?<number>
    (?<integral>
      -?
      \d{1,3}
      (?:[\.,]\d{3}|\d*)
    )
    [\.,]
    (?<fraction>
      \d{2,3}
    )
  )
  (?<currency_postfix_with_space>
    [ \t]?
    (?<postfix_or_ending>
      (?<currency_postfix>
        €|EUR|\$|USD
      )
    ) | (?<ending>
          [ \t]|$|\n
        )
  )/x
Re:Natural occurring molecule rivals Ozempic in weight loss,... by dleeftink on Friday March 07, 2025 @10:13AM (#43290792)
I'd imagine many nested named capturing groups may trip even the best automated system! I do like the solution though.

I would've probably approached it differently, trying to first get the 'inverted' match (i.e. ignore anything that isn't a currency-like pattern) and refine from there. A bit like this one I did a while back, to parse garbled strings that may occur after OCR [0]. I imagine the approach does not translate fully, because it's pattern extraction rather than validation.

[0]: https://observablehq.com/@dleeftink/never-go-nuts

Re:Natural occurring molecule rivals Ozempic in weight loss,... by janfoeh on Friday March 07, 2025 @10:54AM (#43291185)
Thanks for sharing! I have to admit I do not have the necessary brain cycles to spare today, but OCR processing is indeed of interest to me, and I will take a more in-depth look in the upcoming days.

The idea of an exclusionary approach sounds interesting as well. I'll have to think about that a bit.

Re:Natural occurring molecule rivals Ozempic in weight loss,... by dleeftink on Saturday March 08, 2025 @12:12AM (#43297663)
Check out WordNinja in case regex doesn't cut it! [0]

[0]: https://github.com/keredson/wordninja

Re:Natural occurring molecule rivals Ozempic in weight loss,... by janfoeh on Saturday March 08, 2025 @06:23AM (#43299321)
Will do, thanks again!