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. Need Help....don't wnat a space ?

Need Help....don't wnat a space ?

Scheduled Pinned Locked Moved C#
helpquestion
6 Posts 4 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.
  • P Offline
    P Offline
    pakpatel
    wrote on last edited by
    #1

    if i say Enter your full name :Peter Alian Smith So this name has to be start from char no space from starting name. once user write his first name only one space allow not more then one space. again user write his middle name and only one space allow not more then one space... So is that anyone can help me.what should i use ? -Thanks

    Peter

    C 1 Reply Last reply
    0
    • P pakpatel

      if i say Enter your full name :Peter Alian Smith So this name has to be start from char no space from starting name. once user write his first name only one space allow not more then one space. again user write his middle name and only one space allow not more then one space... So is that anyone can help me.what should i use ? -Thanks

      Peter

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Why do you need it to be so strict ? The Trim method removes leading and trailing spaces. A regex or a split and then rejoining with only one space would fix the rest.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      P 1 Reply Last reply
      0
      • C Christian Graus

        Why do you need it to be so strict ? The Trim method removes leading and trailing spaces. A regex or a split and then rejoining with only one space would fix the rest.

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        P Offline
        P Offline
        pakpatel
        wrote on last edited by
        #3

        is there any other method i can use here ?

        Peter

        R C 2 Replies Last reply
        0
        • P pakpatel

          is there any other method i can use here ?

          Peter

          R Offline
          R Offline
          Rajasekharan Vengalil
          wrote on last edited by
          #4

          You mean, you tried Christian's suggestion and it didn't work?

          -- gleat http://blogorama.nerdworks.in[^] --

          Once we figured out that taking our shoes and socks off would double our counting ability the technical glitch was quickly rectified.

          -- Chris Maunder, from the CP newsletter

          1 Reply Last reply
          0
          • P pakpatel

            is there any other method i can use here ?

            Peter

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Why ? Are you thnking I am trying to keep the good methods a secret ? A regex is your best bet. Splitting and rejoining the string is more code, and messier, but perhaps easier to understand. If you don't want either of those methods, I recommend prayer.

            Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            P 1 Reply Last reply
            0
            • C Christian Graus

              Why ? Are you thnking I am trying to keep the good methods a secret ? A regex is your best bet. Splitting and rejoining the string is more code, and messier, but perhaps easier to understand. If you don't want either of those methods, I recommend prayer.

              Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Christian Graus wrote:

              keep the good methods a secret

              Yeah, let's not tell him about name = name.Trim().Replace ( "\t" , " " ).Replace ( " " , " " ) ; as it's far too advanced. :-D

              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