Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Split a string without a delimiter (C#)

Options
  • 15-10-2008 12:14pm
    #1
    Closed Accounts Posts: 20


    I need to split a string : ORDER1234
    into ORDER and 1234.

    I could use a loop to split them but was wondering if you lads know of any handy functions (C#)?
    I can't use a delimiter.

    Cheers


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    You're going to need some form of pattern if you want to split the string.

    Will it always be Alpha Text followed by numbers?

    If so, you just look for the occurence of the first digit in the string, then chop the string in two at that point.

    Don't know a whole lot about C# but check out the Regex class.


  • Closed Accounts Posts: 20 Whackhead


    seamus wrote: »
    You're going to need some form of pattern if you want to split the string.

    Will it always be Alpha Text followed by numbers?

    If so, you just look for the occurence of the first digit in the string, then chop the string in two at that point.

    Don't know a whole lot about C# but check out the Regex class.

    Cheers for the reply.

    That was the problem, the pattern was going to change frequently. I have convinced by partner in crime to stick a delimiter in his barcodes, he was just being lazy!

    Thanks again.


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    Regex and store the pattern in a database/config file..


  • Closed Accounts Posts: 1,444 ✭✭✭Cantab.


    Whackhead wrote: »
    I need to split a string : ORDER1234
    into ORDER and 1234.

    I could use a loop to split them but was wondering if you lads know of any handy functions (C#)?
    I can't use a delimiter.

    Cheers

    Lol. C# programmers...


  • Registered Users Posts: 2,494 ✭✭✭kayos


    Cantab. wrote: »
    Lol. C# programmers...

    Huh? You have a problem with people who program in C#? GG


  • Advertisement
  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    kayos wrote: »
    Huh? You have a problem with people who program in C#? GG
    Well you know, if you're not manually arranging the bits on the platter with a magnetised needle, it's not real programming...


  • Registered Users Posts: 11,980 ✭✭✭✭Giblet


    kayos wrote: »
    Huh? You have a problem with people who program in C#? GG

    Nah, he had problems splitting strings WITH a delimiter.


  • Registered Users Posts: 2,494 ✭✭✭kayos


    Nah, he had problems splitting strings WITH a delimiter.

    I was wondering what you were on about then I found this
    seamus wrote: »
    Well you know, if you're not manually arranging the bits on the platter with a magnetised needle, it's not real programming...


    So all that time from peeking and poking on the C64 up today I was fooling myself thinking I was a programmer? Well apart from a brief assembly stint on a wang....:D


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Your ma had a stint on my wang last night! *boom boom*

    Seriously, what's with the slagging off other languages? Its obvious that the Whackhead is new to C#. And even if he isn't no one language is better than any other language. As we have said before many times on this forum, good development is choosing what language is best for the particular solution at that time.


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    Can we report the above post for bad punning!


  • Advertisement
  • Closed Accounts Posts: 1,444 ✭✭✭Cantab.


    Nah, he had problems splitting strings WITH a delimiter.

    Typical of individuals trained in "computer games programming" from the lesser-known ITs around the country.


  • Closed Accounts Posts: 1,444 ✭✭✭Cantab.


    kayos wrote: »
    I was wondering what you were on about then I found this

    Quite. When you know how to split a string in one line, it's quite a frustrating experience to have to delve through abstract classes and functions for something that's been around since the 1960s.

    Not to mention that you're probably caught in the limited dimensionality of the Microsoft windows environment.


  • Registered Users Posts: 11,980 ✭✭✭✭Giblet


    Cantab. wrote: »
    Typical of individuals trained in "computer games programming" from the lesser-known ITs around the country.

    I'm not trained in computer game programming, I just did that for fun. Wanna download it? It's available for PC and Xbox 360. Games aren't difficult like string manipulation though, that real time ambient occlusion shader wrote itself basically! And variance shadow maps? It's a shame you need two passes at all, what a waste of time.
    And which "lesser known" IT would that be? The one that got me head hunted by Microsoft?


  • Registered Users Posts: 11,980 ✭✭✭✭Giblet


    Cantab. wrote: »
    Not to mention that you're probably caught in the limited dimensionality of the Microsoft windows environment.

    Says the man who didn't know what the var,usr,sbin,bin, and etc folders were.


  • Closed Accounts Posts: 1,444 ✭✭✭Cantab.


    Says the man who didn't know what the var,usr,sbin,bin, and etc folders were.

    Please, go right ahead and explain to everyone what they all mean.

    I'd like your take on it too. Some interesting stuff came to light on that thread.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Thread Locked. Bans and infractions handed out.


This discussion has been closed.
Advertisement