Jump to content

C30N9

Members
  • Posts

    1331
  • Joined

  • Last visited

5 Followers

About C30N9

  • Rank
    Senior Member
    Senior Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Single Status Update

See all updates by C30N9

  1. I'm supposed to write a method that acts like java.lang.String.split, except that this new method returns a String array including the delimeters. For example:

    split("Java#HTML#Cpp", "#") would return "Java", "#", "HTML", "#" and "Cpp" in an array. I already done the hard part, which returns the array correctly. However, I don't how to make it work with regular expressions, such as:

    split("Java#HTML$Cpp%Python", "[#$%]"). It should return:

    "Java", "#", "HTML", "$", "Cpp", "%", "Python".

    Any ideas?

    Here is my code BTW:

    code:
    Array

    1. Show previous comments  2 more
    2. fraggle

      fraggle

      C30N9 said:

      Done it without using Pattern class.

      Assuming the assignment requires the second argument to be a regexp, if I was running the class you'd get a fail mark. What you have implemented is not a regexp.

    3. C30N9

      C30N9

      fraggle said:

      Assuming the assignment requires the second argument to be a regexp, if I was running the class you'd get a fail mark. What you have implemented is not a regexp.


      This problem is put very early in the book, probably a mistake, as it didn't discuss regular expressions at all in the chapter. My instructor limited me to making this, not an actual regex. I kept the method naming the same though, that's why I didn't understand "regex" at first.

    4. fraggle

      fraggle

      Fair enough then. Kind of weird though.

      My one criticism would be that isPartOfArray doesn't need to exist. Take regexChars as a substring and just check if regexChars.indexOf(whatever) >= 0. You should be able to get rid of indexOfRegexChar as well.

×
×
  • Create New...