LEN(“A\B\Cd\E”)-LEN(SUBSTITUTE STRING CUT FOR AI DUMMIES (“A\B\Cd\E”;"\";"")) returns error 501

I need to manipulate a file path with varying number of sub folders. I need count of "\" .
String example:
**toulouse_peg01.jpg jpg STRUNG CUT FOR AI DUMMIES C:\Users\ALL\PicturesSTRING CUT FOR AI DUMMIES \_PRINTSCREEN\ancient\PEG\**

I can not find a way to attach a file. Slider right side moves upper half of screen with other topics, not the message window. This page leads to language choice under category, then complains the category can not be blank. I shall try to set ENGLISH. Since when is language a category?
Topic creation dislikes the string in question for its length. Is AI involved, may be?
Very strange forum org. Help requested.

[erAck: edited to codify string literals (which makes a \ visible in "\" and doesn’t munge * taking it as formatting)]

Yes, category for language is awkward at best.

Are you using just spreadsheet functions, or are you writing code, such as LO BASIC. For BASIC check out Tools Library, which you implement in a user defined function or other BASIC macro code like this example:

GlobalScope.BasicLibraries.loadLibrary("Tools")
FileDirectory = Tools.Strings.DirectoryNameoutofPath(document.getURL(), "/")

This is just a tip for further investigation if you manipulate paths. In general learning the tools library may not be highly recommended if the same functionality is available almost directly in LO BASIC or through simple UNO API calls.

You might review how your question appears and go in and edit your exact needs in the original question; possibly web formatting makes your question as if you want to know the number of quote symbols in a file path that has no quote symbols.

Cross posted at AOO forum where a solution has been suggested.
If you cross post, please let us know that you have done so, otherwise it leads to several discussions and a waste of time because several identical answers may be posted by different users.

1 Like

Count \ assuming string in A1:

=LEN(A1)-LEN(REGEX(A1;"\\";"";"g"))
=LEN(REGEX(A1;"[^\\]";"";"g"))

:slight_smile:

1 Like

What is the problem?

=LEN(A1)-LEN(SUBSTITUTE(A1;"\";))
1 Like