Coder Social home page Coder Social logo

Comments (8)

bakugo avatar bakugo commented on September 3, 2024 1

The correct regex to use here is /^.*\bftms?\b/i. Use regex101.com if you want an explanation of how it works.

@saxamaphone69 That answer by ChatGPT is blatantly wrong in several ways (as LLM answers often are). Copy-pasting shitty AI generated answers you don't understand helps nobody.

from 4chan-x.

saxamaphone69 avatar saxamaphone69 commented on September 3, 2024

image

Give /^ftm/i a go as I'm not sure if newlines even count when filtering. If you don't care where the "ftm" is, omit the ^.

from 4chan-x.

ars4l4n avatar ars4l4n commented on September 3, 2024

just /^ftm/i didn't do anything
What am I supposed to do with the javascript regex. I entered the code (not sure if I did correctly cause I can#t see part of your image) and it blocked some of the ftm messages but most remained. No idea what was going on there

from 4chan-x.

ars4l4n avatar ars4l4n commented on September 3, 2024

The correct regex to use here is /^.*\bftms?\b/i. Use regex101.com if you want an explanation of how it works.

awesome, that worked but the explanation on regex101 confuses me because it doesn't state which part of it is responsible for selecting the line.
I noticed that I need it to filter line 2 and 3 as well

from 4chan-x.

bakugo avatar bakugo commented on September 3, 2024

the explanation on regex101 confuses me because it doesn't state which part of it is responsible for selecting the line.

  • ^ means start of the comment.
  • .* means a sequence of any characters EXCEPT for a newline
  • \bftms?\b is just "ftm" sorrounded by word boundaries, and with an optional s at the end

Effectively this matches any string that starts at the start of the comment, ends with "ftm", and doesn't contain any newlines in between, so effectively just the first line.

If you want to match anywhere in the first 3 lines instead, you can use /^.*(\n.*){0,2}\bftms?\b/i instead, but at that point I don't see why you wouldn't just filter in the entire comment.

from 4chan-x.

ars4l4n avatar ars4l4n commented on September 3, 2024

Effectively this matches any string that starts at the start of the comment, ends with "ftm", and doesn't contain any newlines in between, so effectively just the first line.

complicated...

If you want to match anywhere in the first 3 lines instead, you can use /^.*(\n.*){0,2}\bftms?\b/i instead, but at that point I don't see why you wouldn't just filter in the entire comment.

awesome!
it's because I'm trying to filter out ftm as a means to not have to interact with them but some bios contain "not looking for:ftm" at the end which would make me filter those out too if I didn't use your code.

from 4chan-x.

saxamaphone69 avatar saxamaphone69 commented on September 3, 2024

@bakugo all good, I have no idea how regex works and I find asking ChatGPT a good starting place, tweaking the bits I need, and doing more research from there. I then usually have regexr or regex1010 with an example of the comment/string I want to filter and tweak from there/ask ChatGPT for different options if I can't work it out on my own. I wasn't sure it was going to work for what was needed anyway and the fact that I forgot to ask it for "ftm" standalone, which is obvious now, doesn't help.

Glad you got your answer @ars4l4n, close the issue when you're ready.

from 4chan-x.

ars4l4n avatar ars4l4n commented on September 3, 2024

/^.*(\n.*){0,2}\bftms?\b/i

I use slightly changed versions of this and they work for the majority of things I wanted to filter but one thing still doesn't work.
I used: /^.*(\n.*){0,2}\bms?\b/i and thought it should filter m in line 1:

m
looking for
I'm just looking for someone to trauma dump on me, then leave
bonus points if you're literally insane because I'm having a boring night. Entertain me.
contact
_censored

I suspect that it's because m is the only "word" in the line but I don't know for sure.
How do I solve this? Note that I don't want to filter the letter "m" when it's actually within a word

Also, how do I not filter 'm such as in I'm while still filtering /m/ or m

from 4chan-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.