Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to convert ...

How to convert ...

Scheduled Pinned Locked Moved C#
tutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 9427106
    wrote on last edited by
    #1

    I wanna to convert this string : "

    if("2" == "2" && "10" >="9")
    return "true";
    else
    return "false";

    if the above string contains any of these : >= , <= , > , < Replace the part of string ( "10" >= "9") TO : ( 10 >= 9) So the final string would be :

    if("2" == "2" && 10 >=9 )
    return "true";
    else
    return "false";

    How is it possible. note : the string may contain lot of these math operation in it .

    P 1 Reply Last reply
    0
    • U User 9427106

      I wanna to convert this string : "

      if("2" == "2" && "10" >="9")
      return "true";
      else
      return "false";

      if the above string contains any of these : >= , <= , > , < Replace the part of string ( "10" >= "9") TO : ( 10 >= 9) So the final string would be :

      if("2" == "2" && 10 >=9 )
      return "true";
      else
      return "false";

      How is it possible. note : the string may contain lot of these math operation in it .

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Create a token parser. So, start at the beginning of the string and work your way over it looking for the strings you're interested in. You could do this with a regex and some fancy parsing, but I would keep it simple if I were you. There are some shortcuts that you can take, such as only needing to store the right hand side of the token if the operators are the ones you are interested in. I would also look to split my string up into an array of smaller strings using the && and || operators. Then, I would perform my search on the smaller arrays.

      S 2 Replies Last reply
      0
      • P Pete OHanlon

        Create a token parser. So, start at the beginning of the string and work your way over it looking for the strings you're interested in. You could do this with a regex and some fancy parsing, but I would keep it simple if I were you. There are some shortcuts that you can take, such as only needing to store the right hand side of the token if the operators are the ones you are interested in. I would also look to split my string up into an array of smaller strings using the && and || operators. Then, I would perform my search on the smaller arrays.

        S Offline
        S Offline
        Star
        wrote on last edited by
        #3

        If the text will contain proper spacing..You may use "Contains ()". string strMyText = "There is some text like 10 > 9"; if(strMyText .Contains("10 > 9")) { str

        MyText

        = "I got It"; }

        1 Reply Last reply
        0
        • P Pete OHanlon

          Create a token parser. So, start at the beginning of the string and work your way over it looking for the strings you're interested in. You could do this with a regex and some fancy parsing, but I would keep it simple if I were you. There are some shortcuts that you can take, such as only needing to store the right hand side of the token if the operators are the ones you are interested in. I would also look to split my string up into an array of smaller strings using the && and || operators. Then, I would perform my search on the smaller arrays.

          S Offline
          S Offline
          Star
          wrote on last edited by
          #4

          If the text will contain proper spacing..You may use 'Contains ()'.

          string strMyText = "There is some text like 10 > 9";
          if(strMyText .Contains("10 >9"))
          {
          strMyText = "I got it"
          }

          P 1 Reply Last reply
          0
          • S Star

            If the text will contain proper spacing..You may use 'Contains ()'.

            string strMyText = "There is some text like 10 > 9";
            if(strMyText .Contains("10 >9"))
            {
            strMyText = "I got it"
            }

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            Okay, two things: 1. The OP does not get notified of answers to someone other than them. 2. Your solution does not even begin to address what the OP has asked for. Take a look at his question again and ask yourself if you have really answered it.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups