"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Ulf Dittmer wrote:It had better get improved, as it doesn't work :-) That expression doesn't report "Found" for "wat", for example.
Removing the square brackets was a wrong move - you need those. But judging by how you arranged the "$" and "*" characters I don't think you understand yet what those do.
Quiddo Quitch wrote:
Ulf Dittmer wrote:It had better get improved, as it doesn't work :-) That expression doesn't report "Found" for "wat", for example.
Removing the square brackets was a wrong move - you need those. But judging by how you arranged the "$" and "*" characters I don't think you understand yet what those do.
Do you really have an answer ?
i asked the same question @ the official Sun forum, and ppl say things like this ...
"... there's no syntax in regular expressions to accomplish this. Try turning your string into a character array, sorting it, and then do a simple comparison ..."
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Ulf Dittmer wrote:Yes, I have a solution. The regexp is 9 characters long, 6 of which you already had in your first post. The other 3 I mentioned in my reply.
Quiddo Quitch wrote:
Ulf Dittmer wrote:Yes, I have a solution. The regexp is 9 characters long, 6 of which you already had in your first post. The other 3 I mentioned in my reply.
lol ! i hope you are not having fun with me ... did you tried ? for example if you search "ret" gives you a possitive result ?
i tried every possible combination of what you said
and i know whats ^ and * means, but i don't know quite wll what $ does, i searched @ yahoo and the informations about $ was very poor![]()
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Quiddo Quitch wrote:for example if you search "ret" gives you a possitive result ?
Campbell Ritchie wrote:No need to search Google or anything: just search the Java™ Tutorials.
Quiddo Quitch wrote:
Campbell Ritchie wrote:No need to search Google or anything: just search the Java™ Tutorials.
i did it, is in my second post, no luck in there ... i keep reading anyway ...
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Ulf Dittmer wrote:
Quiddo Quitch wrote:for example if you search "ret" gives you a possitive result ?
Well, that sounds like a different problem. What I had understood was that the string being matched should consist only of characters in the pattern; but apparently that's not what you're asking?
You're looking to match strings that include all characters in the pattern at least once, but can also contain other characters?
You will find $ in this section.Quiddo Quitch wrote:i did it, is in my second post, no luck in there ... i keep reading anyway ...
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Campbell Ritchie wrote:
You will find $ in this section.Quiddo Quitch wrote:i did it, is in my second post, no luck in there ... i keep reading anyway ...
Rusty Shackleford wrote:Yes it can be done.
Show what you have and explain what you think it means and maybe we can move you forward.
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
for example :
t match "water"
ret match "water"
retaw match "water"
wret match "water"
BUT
'i' DOESNT match "water" because 'i' is not in the string "water"
watzer DOESNT match "water" because 'z' is not in the string "water"
Do you really have an answer ?
i asked the same question @ the official Sun forum, and ppl say things like this ...
"... there's no syntax in regular expressions to accomplish this. Try turning your string into a character array, sorting it, and then do a simple comparison ..."
It looks like you are blindly trying combinations, which will not work.
Henry Wong wrote:
for example :
t match "water"
ret match "water"
retaw match "water"
wret match "water"
BUT
'i' DOESNT match "water" because 'i' is not in the string "water"
watzer DOESNT match "water" because 'z' is not in the string "water"
Basically, you want all the characters in the first string to appear in the second string.
Do you really have an answer ?
i asked the same question @ the official Sun forum, and ppl say things like this ...
"... there's no syntax in regular expressions to accomplish this. Try turning your string into a character array, sorting it, and then do a simple comparison ..."
Regex doesn't do AND operations very well -- so I am not surprised if someone told you this can't be done with a single regex match. However, there is a (single regex) solution here... but, as Rusty mentioned...
It looks like you are blindly trying combinations, which will not work.
The solution is not simple (it requires zero length look aheads). And based on what you have done so far, you probably need to read up on your regex a bit more to understand it. I can't even give you a hint in the right direction...
Henry
why you cant give me a hint ?
Henry Wong wrote:
why you cant give me a hint ?
Because I don't know how to explain it... short of asking you to read up on regex. Anyway, here is your solution with a regex that works.
Henry
Ulf Dittmer wrote:It had better get improved, as it doesn't work :-) That expression doesn't report "Found" for "wat", for example.
Removing the square brackets was a wrong move - you need those. But judging by how you arranged the "$" and "*" characters I don't think you understand yet what those do.
David Newton wrote:That pattern would mean the string *must* start with "wat" precisely, which I don't believe is the requirement.
David Newton wrote:Did you try it and see? What will the first asterisk do?
The first asterisk obviously is an wildcard to accept any characters.
David Newton wrote:
The first asterisk obviously is an wildcard to accept any characters.
Here, by "obviously", I think you mean something other than its traditional meaning, unless you had a typo in your original regex.
If the first "*" accepts any characters, what's the ".*" part do?
OMG !!! that is almost what i want ...
(?=.*w)(?=.*w)(?=.*w)(?=.*w)" --> true, but it should be false because "water" has only ONE 'w'
Squanch that. And squanch this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
|