Breaking up text / tokenisers / etc

Hi.
Basically, the intended function of this is to convert this user input:
System 2:290
Slot      Name (activity)      Moon      Deb      Player (status)      Alliance      Actions
1                               
2                               
3                               
4      mampara                stick it (i v)      RoyalG.C      Espionage write message Buddy request
5      ricochet                Man on fire (i v)      RoLUE      Espionage write message Buddy request
6      Marte                Ninrod (n)           Espionage write message Buddy request
7      Larissa                han (v)           Espionage write message Buddy request
8      Colony                Haxor      INC.WING      Espionage write message Buddy request
9      HeroEarth      moon           Blackmage (v)      IPC      Espionage write message Buddy request
10      Homeworld                alek11 (i v)           Espionage write message Buddy request
11      G2-2      moon           Optimax      T.L.S      
12      Colony                Alphidlus      MoA      View Espionage Report Espionage write message Buddy request
13      fujimama                adam15243 (n)      DTSB      Espionage write message Buddy request
14                               
15      Shan0                Kopaleto (v)      BBA.EF      Espionage write message Buddy request
16     Outer Space
(11 planets colonized )      Legend
1 Espionage probe(s)         1 of 11 slot(s) in useAnd for each line with a number (1 --> 15) next to it, produce:
planetName (This is the next bit after the number, e.g for line 9 the planetName is HeroEarth)
moon (This is set either by the word moon exisiting, or not, e.g line 9 has a moon, line 10 dosn't).
playerName (This is the next bit after moon (if a moon exists) or is after the planet name..e.g line 11 is Blackmage, line 10 is alek11)
alliance (This bit is the bit after the playerName, which is not in brackets, e.g line 9 the alliance is IPC).
Now i'm using various methods to clear the whitespace etc. Here is the code that i'm currently using (its a mess, and probably not the best method at all).
        Scanner s = null;
        try {
            s = new Scanner(new BufferedReader(new StringReader(spyReportText.getText())));
            s.useDelimiter("Espionage write message Buddy request");
            while (s.hasNext()) {
                // This has sorted it into an unsorted row
                // 9      HeroEarth      moon           Blackmage (v)      IPC
                // 10      Homeworld                alek11 (i v)
                // System.out.println(removeSpaces(s.next()));
                StringTokenizer st = new StringTokenizer(removeSpaces(s.next()), " ");
                    while (st.hasMoreTokens()) {
                        System.out.println(st.nextToken());
        } finally {
            if (s != null) {
                s.close();
    static String removeSpaces(String withSpaces) {
        java.util.StringTokenizer t = new java.util.StringTokenizer(withSpaces, "     ");
        StringBuffer result = new StringBuffer("");
        while (t.hasMoreTokens()) {
            result.append(t.nextToken());
        return result.toString();
    }To an extent that is working, the output from it gives me tokens, however I have no idea how to go about assigning the tokens to the variables I described, because the token number change per line. For example having a moon affects whether the playerName token is the 2nd or 3rd token.
I'd like a bit of feedback on how you'd approach the problem, if you'd do the whole thing another way etc as i'm hitting a brick wall now.
(P.S, here is the current outcome of that code)
1
2
3
4
mampara
stick
it
(i
v)
RoyalG.C
5
ricochet
Man
on
fire
(i
v)
RoLUE
6
Marte
Ninrod
(n)
7
Larissa
han
(v)
8
Colony
Haxor
INC.WING
9
HeroEarth
moon
Blackmage
(v)
IPC
10
Homeworld
alek11
(i
v)
11
G2-2
moon
Optimax
T.L.S
12
Colony
Alphidlus
MoA
View
Espionage
Report
13
fujimama
adam15243
(n)
DTSB
14
15
Shan0
Kopaleto
(v)
BBA.EF
16Outer
Space
(11
planets
colonized
Legend
1
Espionage
probe(s)
1
of
11
slot(s)
in
useAs you can see, some of it should be easy to assign the variables:
11
G2-2
moon
Optimax
T.L.SWhereas others will be slightly harder..
9
HeroEarth
moon
Blackmage
(v)
IPC(As the alliance is IPC not (v).)
Edited by: allydm on Jan 21, 2008 8:55 PM
Edited by: allydm on Jan 21, 2008 8:57 PM

Ah, that's deffinatly helped to sort it much more efficiently.
Although, I'm still pretty stuck on how to get it to assign the variables corrently.
For example, the code now outputs:
4 mampara stick it (i v) RoyalG.C
From that, I need the variables...
planetSlot = 4
planetName = "mampara"
moon = 0
playerName = "stick it"
allianceName = "RoyalG.C"
Or for a planet with a moon (e.g: 9 HeroEarth moon Blackmage (v) IPC ) , the variables:
planetSlot = 9
planetName = "HeroEarth"
moon = 1
playerName = "Blackmage"
allianceName = "IPC"
I hope that makes sense, any input you can give me will help (and you've already been very helpful :) ).

Similar Messages

  • I just bought my first Iphone the 5S and when I turn on my bluetooth the ringtone for my text, calendar, etc. comes through my Bluetooth instead of the phone. Is there a way to have the tones use the phone while bluetooth is on?

    I just bought my first Iphone the 5S and when I turn on my bluetooth the ringtone for my text, calendar, etc. comes through my Bluetooth instead of the phone. Is there a way to have the tones use the phone while bluetooth is on?

    I would also like this issue addressed.
    I am using a Plantronics Voyager Pro+ and when it is connected to my iPhone 4, email and text sounds are not audible through the phone. The phone just vibrates when a new text or email is received.
    I don't really care if it plays through the headset, but it should at least play through the phone. I tested the headset from a BlackBerry and the alerts play fine.
    Message was edited by: picardsm

  • HP PhotoSmart C309g Printer no longer prints Black Text, Graphics, etc

    Hi:
    We have an HP laptop.
    We have an HP PhotoSmart All-In-One C309g Wireless printer/scanner/copier.
    It has been working fine for a couple of years, until 2 days ago.
    It will no longer print anything in black (colors and Photo Black work fine).
    We have taken it apart...removed all ink cartridges, removed the cartridge caddy,
    cleaned all electrodes,  replaced the caddy, installed 5 (all) new cartridges,, etc.
    We went through the process of removing the cartridges, caddy, shutting down,
    removing the AC cord, waiting for several minutes, then doing the reverse process.
    When we turn the printer on, it does its auto-check/install, and after about 4-5 minutes
    tells us that the installation failed, the to press the OK  button.
    We went thorugh this process several times, and the installation failed every time.
    In the past, installing printer cartridges, cleaning, calibrating...executed quickly.
    The printer will not print anything that is Black, whether it me a print from Word, Notepad,
    doing a direct copy from the glass, etc....both, with the laptop On or Off, but it will not
    print anything in standard Black.
    The colors and Photo Black print fine, but the regular Black does not.
    The output from the other 4 cartridges are sharp, crisp, etc.
    Anything... text, graphics, etc.,  in standard Black does not print.
    Any ideas.
    Thank you
    -DaleBr
    This question was solved.
    View Solution.

    The troubleshooting steps in this document may help resolve the issue of black not printing.  If not see the post here.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Can you put line break in text in the data box when creating a chart.  i.e. if you have a bar chart

    Can you put line break in text in the data box when creating a chart.
    i.e. if you have a bar chart with text underneath each bar, can you break it when you’re entering it instead of manually afterwards
    Thanks

    http://help.adobe.com/en_US/illustrator/cs/using/WS3f28b00cc50711d9fc86fa8133b3ce158e-8000 .html
    See "Enter labels"

  • Contact phone numbers show instead of contact names on my iPad in text messages etc. How do I change it so their names show

    contact phone numbers show instead of contact names on my iPad , text messages etc. How do I change it so their names show

    Did you change your sim card? I had this same problem because I moved countries and had to add a 1 before the number and area code.

  • Contact phone numbers show instead of contact names in phone favorites, text messages etc. How do I change it so their names show

    contact phone numbers show instead of contact names in phone favorites, text messages etc. How do I change it so their names show

    Did you change your sim card? I had this same problem because I moved countries and had to add a 1 before the number and area code.

  • Adding text boxes, etc on top of background image (bitmap)

    I have an image (saved as a bitmap that I created in a drawing program) and I want to add it as a background to one of my panels in my swing application. I need to be able to put stuff on top of it, such as text boxes, etc. What is the best way to get this image as the background????

    I converted the image to a jpg and tried to then used the code in the thread though my situation is a little different since I want to add the image as a backdrop of a JPanel which is inturn a tab on a JtabbedPane. I use the following code but it doesnt seem to work
    ImageIcon icon = new ImageIcon("backdrop.jpg");
    JPanel jPanel13 = new JPanel() {
    public void paintComponent(Graphics g)
    // Approach 2: Scale image to size of component
    Dimension d = getSize();
    g.drawImage(icon.getImage(), 0, 0, d.width, d.height, null);
    setOpaque(false);
    super.paintComponent(g);
    tabbedPane.add(jPanel13, "System Status");

  • Image generator w/ customizable text, colors, etc?

    Hello,
    I was just wondering if there was some sort of module or
    application for ColdFusion that would allow me to generate images
    based on a user's input of text, colors, etc. Something like at
    http://www.finestationery.com...
    http://www.finestationery.com/prod_enter_wording.cfm?prod_id=27502&fss_id=1805200717151002 31481532356810&smain_id=47757042&cm_thiscategory=667&CFID=115729&CFTOKEN=92434145
    ... where the user can type text, set a font, change colors,
    etc, and hit "Preview" to view a generated JPEG with all of their
    personalized options.
    Is something like this available somewhere? Or does Fine
    Stationery just have a bunch of really studly programmers?
    Thanks!

    check out imagemagick (google it 'cos i don't remember the
    url) and
    imagecfc (www.opensourcecf.com/imagecfc/)
    both a free.
    Azadi Saryev
    Sabai-dee.com
    Vientiane, Laos
    http://www.sabai-dee.com

  • I want to increase the ringer volume but not the background volume (ie texts, emails, etc)

    I want to increase the ringer volume but not the background volume (ie texts, emails, etc)

    nigelb999 wrote:
    Can anyone shed some light as to why it's not possible to adjust the ringer volume at the lock screen? Even though it's possible to adjust the volume during music playback and responses from Siri, etc.
    Cannot answer that question. That is a decision made by Apple.
    nigelb999 wrote:
    If there was a profile app available in the app store that allowed me to automatically set different volume levels at different times of the day it would be great - particularly if the app didn't require me to jailbreak the phone.
    There would not be an app like that, as they would not have access to the API. You can provide feedback to Apple if you would like to see this enhancement at http://www.apple.com/feedback and click on the appropriate link.

  • Scaling text, pictures etc. when changing document format in InDesign

    Hi,
    I am making an example of a cookbook layout in InDesign. This is my first time working with the software and I made the document in a totally wrong format. I made a document in 200 x 260 cm, when I was suppose to make it in 200 x 260 mm (duhh).
    So my question is, is it possible to automaticly scale all my text, pictures etc when I change the document format to the correct one? Or do I have to do it all manually?
    Thanks for answers!

    If you've setup your document with margins and guides etc. then scaling it should be ok if you go to Layout>Layout Adjustment and turn this on.
    Then change the size of your document to the new size. You will have a bit of tidying up but it can work.
    Your other option to get you out of this now are to import the InDesign file into a new document at the right size. - http://indesignsecrets.com/zanelli-releases-multipageimporter-for-importing-both-pdf-and-i ndd-files.php
    Or you could request for your printers to resize it this once.
    But you should of course resize this to the correct size.

  • Indesign CS3 what script for Break Out Text Frame ??

    hi expert,
    Indesign CS3 can Break Out Text Frame or Have Script ??
    like this...
    http://img402.imageshack.us/img402/905/20080517085017hb3.jpg
    thank for tell

    you mean - convert/split multicolumn TextFrame to separated TextFrames ?
    for PC or MAC ?
    robin
    www.adobescripts.com

  • Logical breaking of text

    Hi guys,
    I need a help on a particualar scenario where i have a varchar2 field which can have upto 120 characters. I have
    to divide them into three or more and assign each to a variable. One cannot exceed 35 characters. But the
    challenge is... not to break a word if it is within an html tag. In the above example the 35th character is 1
    which is in </h1>. In this case it should break before the tag begins. That means the first variable should
    end at "description" and next variable value should start with </h1>.
    Could you please give some insight on how to handle this?
    Thanks
    <h1>This is a short description</h1><p>This is a product of great value</p>

    This way: But you will have to form three such expressions to populate your variables.
    with data as
      select '<!DOCTYPE html><html lang="en"><head><title>Logical breaking of text | Oracle Forums</title>' col from dual
    select col, case when substr(col, -1, 1) in (' ', '>')
                  then trim(col)
                else
                  substr(col, 1, greatest(instr(col, ' ', -1), instr(col, '>', -1)))
           end col1
      from (
            select substr(col, 1, 35) col
              from data
    COL                                 COL1                           
    <!DOCTYPE html><html lang="en"><hea <!DOCTYPE html><html lang="en">

  • How to break flowing text without deleting parts of it?

    Hello,
    is it possible to break a text that flows across multiple pages in one point without automatically deleting the content of the text boxes below the break? Currently, if I have text flowing across several pages and text boxes, any break that I do at one point ("un-chaining") will result in the text in the following text boxes to be deleted.
    Thanks!    

    Have a look at this thread.

  • Phone Number= Problem with texts, data etc?

    Does anyone know if a phone number is a reason for slow data, text messages etc? Are there any phone issues that can be a result of having a "bad" phone number?
    When I had the iPhone 5, my pic messages were not sending and I was having severe data issues. The replaced the phone twice and the SIM card and I ended up taking the phone back and switching back to my S4 before I got the 5s opening day. What does switching out a SIM card do? Does the SIM card have anything to do with how a phone is receiving data/network signals?

    My friend was telling me she knew someone who had to change their number because their texts and MMS messaging were being funny and not sending/recieving O_O.  Well they switched out the SIM when I previously had the iPhone 5 but this time they didn't do anything, now that you mention it, I think I might just go there after work to have a new SIM inputted because now I'm on 3G 90% of the time instead of LTE and the LTE switch is on. All they did (technician online) recommended a network extender -_- hello that doesn't help me when i'm away from home. smh.

  • I'd like a basic icon in the lock screen to indicate Text, Email etc.  Seems all I can have in lock screen is full alert (with or without detail) or am I missing something?

    I'd like a basic icon in the lock screen to indicate Text, Email etc.  Seems all I can have in lock screen is full alert (with or without detail) or am I missing something?

    I'd like a basic icon in the lock screen to indicate Text, Email etc.  Seems all I can have in lock screen is full alert (with or without detail) or am I missing something?

Maybe you are looking for

  • How can i display console outputs in my form field?

    Hi, I have an application which performs some actions like, insert 200 rows in the database. While inserting data i am using int i=0; system.out.println ("Insert "+i+" row in database"); i=i+1; The output displays on the commnad line what i am trying

  • How do I select multiple Genres at the same time for playback in the new iTunes?

    I used to highlight several Genres at once and hit shuffle, playing all of them. The new iTunes won't let me!

  • I try to bought an app whit my account money

    when i try to bougth annimation desk for macbook pro on the mac app store they told me that i need to choose to paying whit a credit card or whit a apple card but there are no way to buy whit the money that is already on my account... how do i buy it

  • WRT54G & Verizon DSL with Westell 6100g

    Ok here is my problem. I use utorrent for all my downloads. Recently the old wirespeed modem gave up the ghost and Verizon sent me one of their new Westell 6100g. I port forwarded the verizon modem, then briged it to my router. But for some reason ut

  • Importing from iPhoto to PC formatted iPod?

    I have a 5G, 60gig, formerly Mac formatted, now PC formatted iPod. I keep my photos, music, contacts and calenders on the Mac. (I am full time Mac user). I only have USB 1.1 on my PB G4 so uploading video to the iPod is out of the question. This is w