469,330 Members | 1,354 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

checking whether string does not exist with out using !~

Hi guys...

I want to check whether string does not exist with out using !~ .

basical for character we check like that using [^ ].
How to do the same for word, sentence ?....
I actually need as a part of one of my project


Thank you,
Sateesh.
Feb 10 '07 #1
19 8601
KevinADC
4,059 Expert 2GB
http://www.perl.org/books/beginning-perl/

read the regular expressions chapter.

You might also look into the index() function, might do what you want, hard to say though, your question is vague and a bit confusing.
Feb 10 '07 #2
Hi,
Thanks for nice reference. After going through that one also, I could not
able to solve my problem.

case 1 ) single char

!~/a/ equivalent to =~/[^a]/

case 2) total sentence

!~/$sentence/ equivalent to ?.


Ok my problem clearly is finding equivalence in case 2 as in case 1.
There is one function in frame work which takes regular expression and
does pattern matching using =~ .

But there are also certain strings which I would like to not match, eventually
I mean !~. But as I can not change function in fixed framework I have, I want
to change regular expression in such a way.

Thank you,
Sateesh.












http://www.perl.org/books/beginning-perl/

read the regular expressions chapter.

You might also look into the index() function, might do what you want, hard to say though, your question is vague and a bit confusing.
Feb 10 '07 #3
KevinADC
4,059 Expert 2GB
still very vague, but maybe you want to use the string operator 'ne' (not equal) if you're checking an entire string.

Expand|Select|Wrap|Line Numbers
  1. if ($string ne 'this is a sentence') {
  2.    ....
  3. }
  4.  
read the book I linked you to. I am sure it will help you.
Feb 11 '07 #4
Operator =~ is fixed, it's in one of the functions that I can use only (no edit
permission), now I have to play with regular expression to make it
not equal to...

like in case 1, I want to not match char "a", I used [^a] although using =~.

Now similarly for sentence I can not used [^sentence], so I have to find out
regular expression which does this. Hope I made some sense.

Thank you,
Sateesh.
Feb 11 '07 #5
KevinADC
4,059 Expert 2GB
Why are you restricted? Is this school work?
Feb 11 '07 #6
:), If it is school work I would have opposed my teacher :).
But it's basically part of my job in oracle, where the function is in one of
the package that we are integrating with. So I can only play with regular
expression that I pass as parameter and not function.

Thank you,
Sateesh.
Feb 11 '07 #7
KevinADC
4,059 Expert 2GB
OK, well it's difficult to help with a blind-fold on. My best advice at this time is read some regexp tutorials and decide what will work within the limitations placed upon you:

http://perldoc.perl.org/perlre.html
http://perldoc.perl.org/perlretut.html
Feb 11 '07 #8
@SPABBOJU

You have to deal with a function like
Expand|Select|Wrap|Line Numbers
  1. sub fixedMatchFunc {
  2.   my($string, $pattern) = @_;
  3.  
  4.   return($string =~ m/$pattern/);
  5. }
where the operator '=~' is hard-coded.

If you want a string "not" to match, simply negate the result of the function, like this:
Expand|Select|Wrap|Line Numbers
  1. printf("positive match: %d\n", fixedMatchFunc("this is a sentence", "is a"));
  2. printf("negative match: %d\n", ! fixedMatchFunc("this is a sentence", "is a"));
@KevinADC

*****, are you so arrogant or are you unable to capture the simple problem clearly described by SPABBOJU???

You better avoid to answer, if you are destructive in a way you have exhibited yourself. I can hardly see any benefit to anyone in your answers.

Think about "who" is the blind-fold!

Greetz, Doc
Feb 12 '07 #9
KevinADC
4,059 Expert 2GB
@SPABBOJU

@KevinADC

Jesus, are you so arrogant or are you unable to capture the simple problem clearly described by SPABBOJU???

You better avoid to answer, if you are destructive in a way you have exhibited yourself. I can hardly see any benefit to anyone in your answers.

Think about "who" is the blind-fold!

Greetz, Doc
LOL.... I guess I'm just stupid, because I don't think I'm arrogant. Thanks for your, err..... thoughtful insight. ;)
Feb 12 '07 #10
KevinADC
4,059 Expert 2GB
and BTW,

I'll participate in any thread I want to, regardless of if I totally understand the question/concept or not. Until and unless you are the moderator of this forum and can dictate who particpates and who does not, keep such thoughts to yourself. I don't mind being corrected or informed of a better way or a fault in my thinking or code, in fact I appreciate it, but your condescending attitude is best left at your doorstep my friend. So stick a sock in it Doc. ;)
Feb 12 '07 #11
MMcCarthy
14,534 Expert Mod 8TB
@KevinADC

Jesus, are you so arrogant or are you unable to capture the simple problem clearly described by SPABBOJU???

You better avoid to answer, if you are destructive in a way you have exhibited yourself. I can hardly see any benefit to anyone in your answers.

Think about "who" is the blind-fold!

Greetz, Doc
Doc

Please don't abuse other experts in this way. We encourage everyone to attempt to answer questions rather than leave them unanswered. If any expert gives a wrong answer and you wish to correct it that is of course fine but please do so in a polite and respectful manner.

ADMIN
Feb 12 '07 #12
Doc

Please don't abuse other experts in this way. We encourage everyone to attempt to answer questions rather than leave them unanswered. If any expert gives a wrong answer and you wish to correct it that is of course fine but please do so in a polite and respectful manner.

ADMIN
Dear Admin!

I appreciate a culture of conversation incorporating mutual respect. No question!!!

Have you read this thrad from the beginning? I guess not. (you should!)

If experts are willing to answer questions, they should, regardless which approach they follow. But if someone blames the starter of a thread as "blind-fold" although the problem was outlined clearly, I it's hard to stand the temptation to give a hint about the way the conversation is going on. If someone marks a person who seeks for an answer as stupid, it is far away from respect to this person. Again: the question was asked clearly and was repeated subsequently and required just a simple answer (see my answer). Why calling him a "blind-fold"? Sorry, but my integrity requires to comment this, at least to give the starter of the thread the response that he is "not stupid".

So: I do NOT want to be violent, the opposite is the case. I just want to block it, whenever I recognize it.

Regards, Doc
Feb 13 '07 #13
MMcCarthy
14,534 Expert Mod 8TB
I appreciate your response doc and where you are coming from.

As an expert myself I have misread an original thread and gone off on a tangent myself so I understand how easy it is to do. In the Access forum (my area of expertise) the experts back each other up when this happens and in a friendly manner point out the error that has been made. I appreciate the fact that you thought Kevin was being rude with his "blind-fold" comment but I read that as he felt like he was working in the dark (information wise).

However, this communication difficulty arose I would be grateful in future if either yourself, Kevin or anyone else who feels an expert has answered a question inappropriately contact either myself or a forum moderator to deal with the issue. My biggest concern is that this kind of argument doesn't happen in a thread and give a bad impression to other members viewing this question.

Please feel free to contact me by PM if you would like to discuss this further. I am happy to leave the matter here.

Mary
Feb 13 '07 #14
I appreciate the fact that you thought Kevin was being rude with his "blind-fold" comment but I read that as he felt like he was working in the dark (information wise).
Well, for the sake of freedom I will take it this way.

I think my misunderstanding of the comment "blind-fold" results from the fact, that I "could see clearly" the problem described in the thread. I simply could not imagine, that someone "could not". That's possibly why I took it the wrong way, eliminating one direction of thinking, because it seemed to be impossible.

Sorry to KevinADC!

Regards, Doc
Feb 13 '07 #15
ashith
8
Can any1 help me out... wat s d CONTROL for tab in C#..Pl help me out.. Thanks
Feb 13 '07 #16
MMcCarthy
14,534 Expert Mod 8TB
Can any1 help me out... wat s d CONTROL for tab in C#..Pl help me out.. Thanks
ashith

Please post your question in a new thread.

ADMIN
Feb 13 '07 #17
KevinADC
4,059 Expert 2GB
doc,

apology accepted, but in the future please ask for clarification about any comments (like blind-fold), I or anyone else makes before jumping to conclusions and posting add hominem attacks and hyperbole. You misunderstood my comment, which I can understand, that is the nature of conversations on forums: they are easily misunderstood in the absense of body language or facial expressions or further elaborations or etc etc etc. Which is why clarification should be the first appeal, and not assumptions punctuated with irrelevant comments.

See, I thought my blind-fold comment was quite clear in meaning, but rereading the post I can see its not. It's open to interpretation. But your inerpretation was far off the mark and your response was unwarranted, even rude and condescending. There is no need for that on webdev/programming forums.

If I am clearly wrong about something, correct me, educate me, and I will return the favor when the tables are turned. If you are unsure about something I say or post, ask for clarification first.

This forum is big enough for all of us but if you find you can't tolerate me for some reason, you might consider moving on, because I plan on sticking around, imperfections and all. But I would much prefer we get along and cooperate in threads as friends, even as competitive ones, even if we are not peers as fas as programming goes, or simply ignore me if you want to. For me, life is simply too short to sweat the small stuff. Nuff said.

Regards,
Kevin
Feb 13 '07 #18
Kevin,

thanx for accepting my apology.

You are absolutely right: if someone is in doubt, he should ask for clarification, before deducing conclusions.

The real problem was: I was not in doubt!

In this sense, you agreed with my behaviour:
"If I am clearly wrong about something, correct me, educate me, ..."
SPABBOJU described his problem so clearly and even repeated it (he was punctiliously (sort of) beating you with explanational evidence), that I could really not imagine that someone could not "see" it (in my eyes the problem was outlined in a very obvious manner). For this reason, I just felt you ignored his explanations, as they were so unambiguous and coherent. But, as it has turned out, I was wrong, fortunately.

For my part: be sure in future I will attempt to interpret comments even in unconventional ways, opening new channels regarding my cognitive patterns grown so far.

I So, let's stay in harmony.

Greetz, Doc
Feb 14 '07 #19
Oops, wrong thread. Sorry!
Feb 20 '07 #20

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by - ions | last post: by
67 posts views Thread by Steven T. Hatton | last post: by
14 posts views Thread by Kayle | last post: by
15 posts views Thread by Geiregat Jonas | last post: by
reply views Thread by Jeff | last post: by
9 posts views Thread by D. Shane Fowlkes | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.