✅ how to find some common strings in array?
I have following strings:
I'd like to return
["astra-srv:658712/sys/broker/state", "astra-srv:658712/svc"]
I think I can't even group these strings24 Replies
No built-in solution, but I think the straightforward solution is optimal
well maybe not optimal actually
@penance Are you trying to find a known or unknown string?
You need to define a lot of parameters to solve this problem
If you know ahead of time what your looking for and you're trying to extract "Frequency" as a feature
Regex
easy
super easy
If you're trying to find the frequency of an unknown word
You're need to define some constraints to start searching and grouping within
unknown strings
oh thanks for the idea
Can you define some constraints?
yes
If you can't you're in the area of NLP
and machine learning
lol
I thought it will be easy
You need to define what a word is
Why?
"findthefindthemostcommonword"
How would you find the most common word in this string?
it is easy to find 1 common word in string
but it's harder to find some common in string
By doing a look ahead?
You need to extract A feature from the string to define what a word even is
Define for me the word boundry of the string I just showed you
There are a few ways to do this depending on your exact requirements
If you have a non-word character you can split by
Happy days
find
find?
Huh?
That is still doing some kind of look ahead
I don't know what method you're specifically talking about (A LINQ method?)
But given a specific input
Yes
Its very easy
using regex?
I just keep looking ahead until Str[n] == Token
And then scan until the end of the boundry
Sure
You can use RegEx
for that
ok, I will try
But if your token is unknown you can not
@penance If you join dev-vc-0 I can better explain your problem to you
I don't think RegEx will work for you
I'm sorry but unfortunately, I won't be able to do it now
I will try to use all my leet code power to solve this problem
Is there a token you can split by that is consistently present in the string?
seems like
/
and :
areyes, it is
/
Try splitting by that
that will give you an array
Then just count how many times you find N item in the array
hm okey but my problem will not be solved any way
->
["astra-srv:658712/sys/broker/state", "astra-srv:658712/svc"]
looks like you jsut want to find the roots?
this should work.
yes, it works, thanks
but I needed to return common paths, not only root
astra-srv:658712/sys/broker/state/
not astra-srv:658712/sys
anyway thanks for your helpyou could probably tweak it a bit based on patterns, but finding "common paths" in entirely unknown strings is hard