none
if (Code.Contains(Code.Text)) problem RRS feed

  • Question

  • in the video you can see that its checks in my website and if it is contains what ever in the txt and website it is doing somthing but i am deleting letters and its still doing like every thing fine and i dont want like that i need somthing other form contains or how do i can fix it.

    video: https://streamable.com/4y6w0

    Friday, November 30, 2018 4:13 PM

Answers

  • Try Regular Expressions:

       if( Regex.IsMatch( User, @"\b" + Regex.Escape( textbox1.Text.Trim() ) + @"\b", RegexOptions.IgnoreCase ) )…


    • Edited by Viorel_MVP Sunday, December 2, 2018 9:25 AM
    • Marked as answer by Noam1248 Sunday, December 2, 2018 7:25 PM
    Sunday, December 2, 2018 9:25 AM

All replies

  • Hello,

    Please clearly explain your question without relying on a video as most members here will not open them.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Friday, November 30, 2018 11:27 PM
    Moderator
  • The contains is broken cuz i was trying to search somthing on a webpage (text) and after a i typed what i need to search it found the text amd after i was deleting a letter and steel was found.

    like i was searching for 'lol' and the text was on the webpage every thing fine ok after that i was searching for a 'lo' and steel it was saying there are a text like that and no text 'lo' on the webpage there was just a 'lol' no more then that.

    "search for a specific text in a web"
    • Edited by Noam1248 Saturday, December 1, 2018 7:01 AM
    Saturday, December 1, 2018 6:50 AM
  • Noam,

    Please post the code you are using. Post the code here in this forum thread.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, December 1, 2018 5:50 PM
    Moderator
  • Saturday, December 1, 2018 6:16 PM
  • Please post code in a code block, not an image.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Saturday, December 1, 2018 7:46 PM
    Moderator
  • Hi Noam,

    There are two things that I can think of that would cause a comparison that you're not expecting.

    1) A different case in the textBox1.Text than in the User. For example, textBox1.Text might be "abc", while the word in User might be "Abc" … Contains() would return false;

    2) The string in textBox1.Text might have an extra space at the end or beginning: "abc " … that would cause Contains() to return false.

    This should produce the results you're looking for:

    if (User.ToLower().Contains(textBox1.Text.ToLower().Trim()))
    ….

    You might want to include a search using a space though, and if that's the case, leave out the .Trim()


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, December 1, 2018 9:18 PM
    Moderator
  • its not what i am searching for.

    i need it will search a word and find it and if the word (in text box) have -letter so it will be false

    if just one change to the word it will be false

    Sunday, December 2, 2018 6:20 AM
  • Try Regular Expressions:

       if( Regex.IsMatch( User, @"\b" + Regex.Escape( textbox1.Text.Trim() ) + @"\b", RegexOptions.IgnoreCase ) )…


    • Edited by Viorel_MVP Sunday, December 2, 2018 9:25 AM
    • Marked as answer by Noam1248 Sunday, December 2, 2018 7:25 PM
    Sunday, December 2, 2018 9:25 AM
  • Omg thank you, you helped me alot.

    again thanks

    Sunday, December 2, 2018 12:51 PM
  • its not what i am searching for.

    i need it will search a word and find it and if the word (in text box) have -letter so it will be false

    if just one change to the word it will be false

    Sorry, Noam … I don't understand what you mean.

    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Sunday, December 2, 2018 2:34 PM
    Moderator