Regex interpretation needed

I read an article at Find Command in Linux With Regex [5 Examples]

They said:

Here the [^/]*\/ referees to the files that do not contain any back slashes which eliminates the possibility of finding files in the current directory.

Did Sugar mean slashes and not backslashes?

Isn’t that backslash in there to escape the slash?

Sidenote: I’m easily annoyed I guess, but it bugs me when you hear a commercial on the radio and they read out a link for more information at the end saying “backslash”. OMG, it’s a forward slash. Just say “slash”. UGH.

3 Likes

You’re right.

[^/]* is any sequence of characters different from the forward slash.

Why the following slash is escaped with a backslash, I don’t know.

However, when it comes to finding files, I personally find locate the better option in most cases.

2 Likes

Locate will give you a list of files that existed when the last ‘updatededb’ was run by cron.

find , will give you files that exist now.

2 Likes

^/ in brackets means not slash, ie any character but slash

  •   means zero or more times
    

/ is an escaped slash

so any sequence of nonslash characters, followed by slash

I think slash outside of brackets has to be escaped because it is a chsracter with a special meaning to regex

I agree with you.

The original post I made was asking if the author of the article mistakenly typed “back slashes” in the description of the regex. I think he meant forward slashes. Not sure why you wouldn’t just say slashes. There wouldn’t be any back slashes in a find for the current directory or any subdirectories and that’s not what the regex is doing anyway.

1 Like

Welcome to the world of infinite frustration. “Non-technical” society has spoken loud and clear: They have no interest in learning how to differentiate between a forward and a backward slash.

Hell, plenty of them can’t tell a colon from a semicolon.

Some even regularly confuse double and single quotes. (Doesn’t help that, while C/C++ treat the two very differently, most other languages let you use them (in pairs) interchangeably. So even coders who aren’t C/C++ coders see it [correctly, to an extent] as, “Eh, what’s the difference?”)

It’s a curse, being a precisionist in an imprecise world.

On that point, I have to disagree. Since the pattern string itself contains both forward and backward slashes, my response to someone “just saying slashes” would be: “Which ones?

(Unless they were discussing both the forward and backward slashes, and referred to the “slashes” as opposed to the “backslashes”, so that it’s clear they mean forward slashes in those cases.)

Finally, one thing I try to impress upon people who are clearly never going to sort out the whole forward/backward slash thing: They can just call them “directory slashes”, which has the added advantage that it translates to forward slashes on Linux/macOS and backslashes on Windows, so they don’t have to keep them straight in their clearly porous brains. (Just… don’t use it when talking about URLs.)

1 Like

Every single word of this post.

Aside from IT, what sincerely drives me nuts is, when people use equal sounding words interchangeably, even though their meaning (semantics) may be very different.

e,g.: there, their, they’re, your, you’re etc.

2 Likes

There are times when the written word needs tombe spoken to make the meaning obvious

Do NOT touch me - it is forbidden
Do not TOUCH me - do something else
Do not touch ME - touch someone else

English relies on emphasis to convey meaning.

1 Like

Very true, indeed.

In German, you may need it in the very same word:

Du sollst Opa umfahren! = You should drive around grandpa.
Du sollst Opa umfahren! = You should drive over grandpa.

Most of the times, though, it should be clear from context what is meant. Unless grandpa has been transformed into a zombie or a vampire, driving him over, shouldn’t be an option.

2 Likes

Not always. That sentence is a biblical reference
Screenshot from 2022-10-23 20-42-24
In latin (Noli me tangere) the emphasis is usually on the first word.
When you translate that to English, it is not at all clear to the reader where the emphasis is. Things are lost in translation.
I have no idea what the original (Hebrew) meant.

1 Like

Oh: That’s easy: “Don’t you fucking dare touch this!”

But generally speaking: Translating something properly is always a bitch. With historic texts, it’s worse.

1 Like

Not so with computer languages. I guess their syntax is much more rigorous?

1 Like

Syntax is not semantics.

However: Compiler building is one of the most complex areas of computer science.

Right , but it does help convey meaning.
For example computer syntax does help with John 20:17

!do - your modern reaction - hands off
!touch - the biblical meaning - dont cling
!me - my paranoid reaction - dont pick on me

It all depends on which word the ‘not’ belongs to. Written English fails to make the meaning clear. English as spoken does a better job.

Compiler building is one of the most complex areas of computer science.

I always wantrped to go there, but never made it. I admire those pioneers who wrote the first compilers in assembler

From an old email on the English language

.English is Difficult? You betcha! Can you read these correctly? .The first time?

  1. The bandage was wound around the wound.

  2. The farm was used to produce produce.

  3. The landfill was so full, they had to refuse more refuse.

  4. Please polish the Polish furniture.

  5. He could be in the lead if he would get the lead out.

  6. The soldier chose to desert his dessert in the desert.

  7. Since there is no time like the present, it is time to present the present.

  8. A bass was painted on the head of the bass drum.

  9. When shot, the dove dove into the bushes.

  10. I did not object to the object.

  11. The insurance was invalid for the invalid.

  12. There was a row among the oarsmen about how to row.

  13. They were too close to the door to close it.

  14. The buck does strange antics when does are around.

  15. A seamstress and a sewer fell down into a sewer line.

  16. To help with planting, the farmer taught his sow to sow.

  17. The wind was too strong for us to wind the sail.

  18. I shed a tear upon seeing the tear in the painting.

  19. I had to subject the subject to a series of tests.

  20. I need to intimate this to my most intimate friend?

3 Likes

Heh. That was actually a line (“welcome to…”) that someone whipped out on me over @ one of the ex-Gawker sites, after I left a Quixotic comment regarding… some article transgression that’s becoming so common, trying to point them out is basically spitting into a hurricane.

(Might’ve been a “literally” that preceded a clearly figurative statement. Because, if you ask 10 people to define “literal”, 8 of them will get it wrong. Yet, I guarantee ALL 10 of them are still using it all the fucking time.)

I forget what journalist’s/editor’s rule was, “If you can’t give me the definition of the word, you don’t get to use it in the article.” But can we get those people back?

(Aside: Why does “yore” never get any love, when discussing homonym confusion? :wink:)

I’m belatedly arriving at the realization that speech-to-text transcription is… not exclusively to blame for that, but is a much bigger contributor than I’d initially realized. Mostly because I hadn’t realized just how many, and how heavily, people rely on text-to-speech speech-to-text nowadays. (I’ve always personally held the belief that the two biggest evils in computing are talking computers, and talking to computers. My only conundrum is deciding which is worse.)

But over time, I’ve gotten better and better at spotting the distinctive type of homonym errors that are almost certainly the fault of voice transcription: “disgust” showing up in place of “discussed”, or “through”/“threw” swaps… errors that are far less likely the fault of a human than of software. And the really surprising thing (to me) is both the frequency, and the diversity of contexts, with/in which I’ll end up spotting those “tells”.

…Not that that’s any excuse. The way I see it, if you have a machine transcribe your words then you have a responsibility to proofread its work and you should fix any errors the software made. But we’ve come full circle on the original premise here: “should” doesn’t count for shit. The majority of people just DGAF and never will.