Split to words and put in an array

I thought this time the split code would work perfect for my situation but it does not. I want to split a sentence by taking each word and putting it in a new element of a string array. So if i had the string " ab cd e ", "ab" would be in position 0, "cd" at 1 and so on. This is the method I have
public static String[] splitToWords(String str){
     return str.split(" ");
}but this brings up
[0] = ""
[1] = "ab"
[2] = "cd"
[3] = " "
[4] = "e"
I think i understand why this is happening. Does anybody know a better solution or how to fix this? The split method looks like it is very useful, but i can never seem to find a good place for it. Thank you for any replies

Hello,
try this codes
public class TestStr{
     public static String[] splitToWords(String str){
          return str.split(" ");
     public static void main(String[] args){
          TestStr t = new TestStr();
          String s1 = " ab cd e ";
          String[] receive = t.splitToWords(s1.trim());
          for(int i=0;i<receive.length;i++){
               System.out.println("The "+i+" is "+receive);
And the result is:
The 0 is ab
The 1 is cd
The 2 is e

Similar Messages

  • How do I create a double page spread in a booklet layout on InDesign with out splitting my design and putting them on two separate pages?

    I'll try my best to put this in the most simplest way,
    Im trying to create a magazine, but I'm finding it difficult to make a double page spread without splitting it in half and putting it on different pages?
    Is it possible to set the pages up so they are side by side, and then change them to the right order to print?

    Just set them up as letter size pages in reader order. If you are having it printed professionally, send it as a pdf with separate pages, and the printer will handle setting up the printer spreads. If you are printing it from an office printer, both InDesign and Acrobat have Print Booklet functions. Many office printers also have this capability built in.

  • How do I create a 1d array that takes a single calculation and insert the result into the first row and then the next calculation the next time the loop passes that point and puts the results in thsecond row and so on until the loop is exited.

    The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
    The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
    pear to be working or at least I am not getting any indication on the inidcator.
    Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
    Attachments:
    regulation_tester_7_loops.vi ‏244 KB

    I didn't really have time to dig in and understand your program in depth,
    but I have a few tips for you that might things a bit easier:
    - You use local variables excessively which really complicates things. Try
    not to use them and it will make your life easier.
    - If you flowchart the design (very similar to a dataflow diagram, keep in
    mind!) you want to gather data, calculate a value from that data, store the
    calculation in an array, and loop while the time is in a certain range. So
    theres really not much need for a sequence as long as you get rid of the
    local variables (sequences also complicate things)
    - You loop again if timepassed+1 is still less than some constant. Rather
    than messing with locals it seems so much easier to use a shiftregister (if
    absolutely necessary) or in this case base it upon the number of iterations
    of the loop. In this case it looks like "time passed" is the same thing as
    the number of loop iterations, but I didn't check closely. There's an i
    terminal in your whileloop to read for the number of iterations.
    - After having simplified your design by eliminating unnecessary sequence
    and local variables, you should be able to draw out the labview diagram.
    Don't try to use the "insert into array" vis since theres no need. Each
    iteration of your loop calculates a number which goes into the next position
    of the array right? Pass your result outside the loop, and enable indexing
    on the terminal so Labview automatically generates the array for you. If
    your calculation is a function of previous data, then use a shift register
    to keep previous values around.
    I wish you luck. Post again if you have any questions. Without a more
    detailed understanding of your task at hand it's kind of hard to post actual
    code suggestions for you.
    -joey
    "nelsons" wrote in message
    news:[email protected]...
    > how do I create a 1d array that takes a single calculation and insert
    > the result into the first row and then the next calculation the next
    > time the loop passes that point and puts the results in thsecond row
    > and so on until the loop is exited.
    >
    > The attached file is work inprogress, with some dummy data sp that I
    > can test it out without having to connect to equipment.
    > The second tab is the one that I am having the problem with. the
    > output array from the replace element appears to be starting at the
    > index position of 1 rather than 0 but that is ok it is still show that
    > the new data is placed in incrementing element locations. However the
    > main array that I am trying to build that is suppose to take each new
    > calculation and place it in the next index(row) does not appear to be
    > working or at least I am not getting any indication on the inidcator.
    >
    > Basically what I am attempting to do is is gather some pulses from
    > adevice for a minute, place the results for a calculation, so that it
    > displays then do the same again the next minute, but put these result
    > in the next row and so on until the specifiied time has expired and
    > the loop exits. I need to have all results displayed and keep building
    > the array(display until, the end of the test)Eventually I will have to
    > include a min max section that displays the min and max values
    > calculated, but that should be easy with the min max function.Actually
    > I thought this should have been easy but, I gues I can not see the
    > forest through the trees. Can any one help to slear this up for me.

  • How to increment an element in an array and put it back in the same array?

    I have an array of values generated by another part of my program. My goal is to count the number of occurences for each integer value in the array and put these values in a new array. This new array will be a histogram of the input array. My approach is to do auto-indexing with a for loop. In the loop I use a "index array" to get the current value of the histogram array and a "replace array subset" to update the array element with "current+1". The problem is that when I wire the output of the "replace array subset" VI back to its input, I get a wire error. I guess I cannot wire it like that, but what should I do? Is there a completely different approach to do this that
    is more elegant?
    Thanks for your help!
    Benoit

    Hi Benoit,
    I believe the thing that's missing is a shift register.
    Right-click on the edge of your "For loop" and select add shift register.
    Wire an initialized array to the shift register left terminal before entering the "for loop". Wire from this same terminal (inside the loop) as the source of the info used in your "index array" and replace array. The results of these two operations (just the way you are doing it now) gets wired to the "right terminal" of the shift register (inside the loop).
    What ever you stuff into the right terminal, gets returned via the left terminal on the next iteration of the loop. When the loop is done, your final array of counts can be accessed by wiring from the "right terminal" (outside the loop).
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to write ABAP code to split a sentence into Word by Word and store them

    Hi all,
        I have to split a sentence into word by word and store them into separate columns. This sentence is nothing but a text description (TXTMD) from table TXXXX. The description will have 3 or more than 3 words and LAST word will be <b>always with %</b>'. The following is the sample input data:
    KEY(ORD43)       Description(TXTMD)
    'AAAA'                '1234  ABCD COMPANY USA  80%'
    'BBBB'                '4745  XYZ INC CANADA ABCD  70%'
    For the first record:
      '1234' should stored in to <b>Field 1</b>, 'ABCD COMPANY USA' into <b>Field 2</b> and
    '80%' into <b>Filed 3</b>.
    For the second record:
      '4745' should stored in to <b>Field 1</b>, 'XYZ INC CANADA ABCD'  into <b>Field 2</b> and 70%' into <b>Field 3</b>.
      The first word into Field 1, the last word with % into Field 3 and all middle words into Field 2. The number of words in the sentence could be 3 or more than 3.
      Could you please help in writing the ABAP for this requirement ????
      Thanks in advance.
    Regards,
    Venkat.

    Easy way if you know the length of the field.
    In my example I assumed my field has 12 places.
    DATA: obs TYPE string,
           bkp TYPE char12.
    obs = '12345678901234567890123456789012345678901234567890'.
    DO.
       MOVE obs TO bkp.
       SHIFT obs BY 12 PLACES LEFT.
       write: / bkp.   "Do what you want with bkp variable
       IF obs IS INITIAL.
         EXIT.
       ENDIF.
    ENDDO.

  • HT201413 i put in a pass word and cant remember it i cannot get into my ipod

    I placed a pass word on my Ipod to stop my sister using it and I have been away and did not take it with me now I cant remember it How can i get rid of the box's to enter my ipod so i can start and use it everytime i try and put in what I thought it is i haft to wait 5 minutes to try again HELP please

    Connect to iTunes on the computer you usually Sync with and Restore...
    If necessary Place the Device into Recovery mode...
    http://support.apple.com/kb/HT1808

  • Split string into two based on end of word and max length

    I have the following procedure, which is passed a comma separated string as it input, and it has to split it into two, and the split has to occur at the end of a word, and the first split part can't be more than 15 in length.
    Is there an more efficient way of achieving this? I have a loop in my main code that calls this procedure and in effect a nested loop has been created here.
    e.g. Hello, everyone, welcome, to, split, string' would be split into 'Hello' and 'everyone, welcome, to, split, string'
    create or replace procedure split_str
                   (pi_str  in  varchar2,
                    po_str1 out nocopy varchar2,
                    po_str2 out nocopy varchar2) is
      i number;
    begin
      if (len(pi_str) <= 15) then
        po_str1 := pi_str;
        po_str2 := NULL;
      else
        i := 1;
        loop
          exit when len(SUBSTR(pi_str, 1 ,INSTR(pi_str, ',', 1, i)-1)) > 15;
          po_str1 := SUBSTR(pi_str, 1 ,INSTR(pi_str, ',', 1, i)-1);
          po_str2 := SUBSTR(pi_str, INSTR(pi_str, ',', 1, i)+2);
          i := i+1;
        end loop;
      end if;
    end split_str; 

    You want to find the last space character before the 15th character.
    x := INSTR ( SUBSTR ( pi_str, 1, 15) , ' ' , -1)Then the first string is SUBSTR(pi_str,1,x) and the second string is SUBSTR(pi_str,x+1)

  • Taking pieces of a signal and putting them in an array

    Lets say I have a square wave in a large array (1X#samples). I want to
    put the values of each positive part of the square wave into an array
    such that its size is #positivepulses X #samplesperpulse. The only
    thing that I know for certain about the square wave is that the
    non-positive parts of the signal are zero.
    Any suggestions for how I might achieve this?
    Sent via Deja.com http://www.deja.com/
    Share what you know. Learn what you don't.

    use the java.util.Scanner class.
    read in the file. loop through the lines to get the numbers and put them into an array and/or add them.
    this is something you could have easily looked up on your own. if not in google, then definitely within these forums.

  • How to take waveform chart data and put it into an array

    Hello all,
    I am new to programming in Labview, and am learning basically by watching youtube video and such. My question is how to take a set of random data that I have written code for and linked to a waveform chart, and put the data into an array so I can calculate the mean of the data set. If there is an easier way to calculate the mean of the data set I am all ears, but I need to be able to display the mean on the front panel each time the code is run. I have attached a file of my code.
    Thanks
    Attachments:
    CA1.vi ‏11 KB

    Welcome.
    If you have not done so, look at the on-line tutorials on Getting Started with LabVIEW on the NI web site.
    A chart has a property known as History which retains some previous values.  You can get access to the the History property by popping up on the block diagram terminal of the chart and selecting Create >> Property Node. Note that the history length can be set via a pop up menu.  The default length is 1024.
    Other comments: When you know the number of iteration in advance you should use a for loop rather than the while loop.
    You can also use an autoindexing tunnel at the boundary of the loop to create an array. It only contains the values from the current run, unlike the chart history which can retain values between runs (as long as the VI remains in memory). Watch the two Mean indicators as you run this VI several times.
    The error wire is to assure that the history property node runs after the loop.  Disconnect the wire and watch the Mean and Mean 2 indicators carefully.
    The Wait is to slow things down a bit so that you can see what is happening.
    Lynn
    Attachments:
    CA1.2.vi ‏11 KB

  • Can I get word document on my iPad and put attachments to an email like a cv.

    Hello,  can I get a windows word document on my iPad and put attachments to an email like a cv.  To send out to future employers.

    There are lots of ways of moving files.
    A simple and popular way to copy files and share files amoung your devices.
    https://www.dropbox.com/
    Using iTunes to transfer files:
    http://support.apple.com/kb/HT4094?viewlocale=en_US&locale=en_US
    More ways to transfer files and access Word documents:
    https://discussions.apple.com/thread/4044866?tstart=0
    All of the "Office" document editing applications on the iPad have limitations.  Best try them out to see if they meet your needs.
    DocsToGo
    • VIEW/EDIT/CREATE Word & Excel files(Office 2007/2008/2010)
    • VIEW PowerPoint, PDF, iWork, Text, .RTF, and more!
    • Send & receive attached supported documents using the built-in Mail app
    • FREE desktop application with your purchase! Compatible on Win & Mac allows you 2-way file sync with a WIFI connection.
    • Open & Edit files within DocsToGo from any 3rd party app that supports the “Open In” feature
    • Supports iTunes File Sharing via USB cable for manually moving files
    https://itunes.apple.com/us/app/documents-to-go-office-suite/id317117961?mt=8
    Thanks to Texas Mac Man for pointing to this link.
    "Quickoffice Connect Mobile Suite and Documents To Go These two apps share an important feature: unlike Numbers, they can open, edit, and save an Excel spreadsheet without stripping out any data or formatting, even though they can’t display or edit all the existing information; spreadsheets can make the round trip from Mac to iPad and back safely, without losing anything."
    http://www.macworld.com/article/1159958/ipadspreadsheet.html
    iWork by Apple
    Keynote
    How to compose PowerPoint presentations that are compatible with iPad Keynote presentations. http://www.pchelps.com/2011/06/from-pc-to-ipad-creating-presentations-that-work/ #comment-2234
    Numbers
    Pages
    Office² HD
    "Office² HD, the most intuitive and straightforward office document editor available on the iPad, makes it easy to open, view, create and edit Word (DOC & DOCX), Excel (XLS & XLSX), and PowerPoint (PPT & PPTX) files right from your iPad!"
    https://itunes.apple.com/us/app/office2-hd/id364361728?mt=8
    Quickoffice Pro HD
    Create and edit ALL Microsoft® Office -- document, spreadsheet, and presentation formats, as well as view PDF files, on the go. Our advanced file manager lets you manage local files, access Google Drive or other cloud accounts, and works with your iPad email attachments so you can work anywhere, anytime - online and offline.
    https://itunes.apple.com/us/app/quickoffice-pro-hd-edit-office/id376212724?mt=8

  • Every time I try to up date my apps and put my pass word  it's  disable.and I have reset everything.  Help !

      I'v been trying to up date my apps and put in my pass word it comes back disabled.I'v reset and changed my pass word several times but I can down load apps.whats up with that.

    Contact iTunes Support.
    http://apple.com/support/itunes/contact/

  • Powershell search for a word and use the next word

    Here is the skinny.  I am trying to easily part through a event log of print jobs.  I export it to a CSV, grab only the events that pertain to what I need but I am stuck there.  Here is a sample of what I need help with.
    Microsoft Word - Test Print owned by user1 on computer1 was printed on printer1 through port
    Obviously document name, user1, computer1 and printer1 will be different in almost every case.  How do I parse through this and grab the username, computer and printer.  I was thinking search for "owned by", but how do I grab the name?
    Thanks for the help.

    ok now I am running into another issue.  Apparently the nuances of splitting by word seems to be los on me.
    when I do
    foreach ($job in $printjob) {        $test = $job.split("owned by")        echo $test}
    It will then split the line by each and ever "o", "w", "n", "e", "d", etc.....  I even tried $test = $job.split("'owned by'").  Any ideas?
    I feel like I should explain why this is happening.
    When you call $job.Split(), you're calling the .NET Split() method of the object System.String.
    If you look at the overloads of split (i.e., all the different ways you can call String.Split) - link here https://msdn.microsoft.com/en-us/library/system.string.split%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396 -,
    you'll notice that the only way of calling String.Split() with a single parameter is if you pass a char[], an array of characters.
    Now, if you were coding in C# or VB.NET and you did... String.Split("owned by"), you'd get an error saying that it's expecting a char[] but you gave it a string.
    Powershell however is a bit 'smarter' and it tries to accommodate... It knows that the method expects a char[] and it knows you gave it a string, but it also knows how to convert it to a char[], so it does that, and that's what the method String.Split()
    receives.
    And what happens when the method String.Split() receives a char[]? It splits on every single character in that char[], as you've seen :)
    How to fix it? Well, there are two overloads that accept a string[], so you can use those. Now here's an interesting fact...
    In the same way that PowerShell converted a string to a char[] to accommodate the needs of the method you were calling, it can also convert a string into a string[], so you could do this:
    $job.Split("owned by", [System.StringSplitOptions]::None)
    You're passing it a string... and a [StringSplitOptions] object, so you expect it to call the third overload from the page I provided earlier.
    But if you run it... you still get the same stuff as before! What gives?
    Well, seeing as in this particular case there is an overload that receives char[] and another that receives string[] and you passed a string, which means PowerShell will always have to convert it into something anyway... You have no control
    over what PowerShell will decide to convert the string to. It could convert to char[] or to string[]. In this case, because the definition of the char[] method appears before the string[], that gets picked.
    So, finally... how to force PowerShell to pick the string[] overload? Well, don't give it a choice!
    $job.Split([string[]] "owned by", [System.StringSplitOptions]::None)
    So here I'm casting the string into a string[] before it gets passed to the method, so PowerShell does not need to perform any conversion itself and everything is right with the world.
    Hope this helps :)

  • Help with creating a list, adding to it, calling it and putting it in a combobox with c#

    I have been making a word RPG game with the windows form in c#, and I have encountered some problems along the way. Right now I have a character creation screen, and a screen that displays all of the stats, and gear equipment. I was thinking about adding
    some basic/starting items and put the list into a combobox. I created a separate class and named it HeadItems.cs, and put all of the possible stats, as well as ID and string name. I set a constructor with many parameters, so I can simply input this code, and
    have it generate a head item.
    HeadItems.Add(new HeadItem("Test Head", 0,2,0,0,1));
    Then I was trying to make the combobox, called cboHeadItems, and put its DataSource as HeadItems. Though I am not sure how to get it so it displays the first array, or the string name in the combobox. I am also not sure if I should create the list in the
    player entity class or its own class. From there I am not sure how to call the list on other forms/classes or how to make the name appear in the combobox for people to select.

    Hiya!
    It isn't that simple I'm afraid! You cant make the datasource of a combobox a 'HeadItem' because it doesn't know what that is and it won't know how to handle it.
    There are a few different ways to do it. You can pass it an array, a dataset, a datatable to mention just a few.
    Probably the simplest way is this:
    foreach(HeadItem hi in HeadItems){
    comboBox1.Items.Add(hi[0]); //Depends on your setup
    Antony
    :D

  • Having trouble converting array to spreadsheet string, storing the file and coverting back to array with complex numbers

    I am working with a network analyzer. I have arrays made of 5 columns the first consisting of an integer and the next four consisting of complex numbers. I am converting the array into a spreadsheet string and then saving the file using the write characters to a file VI. That seems to work well as when I open the file in Excel all the data is there. However when I try to reverse the process, open file and convert back to array, I loose some of the data. Specifically the imaginary parts of my complex numbers are all going to zero. I have narrowed down the problem to be in the conversion from spreadsheet string to array and vice versa. I
    think the problem may be with the 'format' input to the VI. I do not have an adequate resource for this so I am not sure what to put in to accomplish my task. Any takers?

    Hi Biz
    I don't think there is a direct way of converting a complex number to a
    string, so when you convert the array to a spreadsheet string, the
    numbers would be converted to real data.
    However, you could try separating the real and imaginary parts using the
    "Numeric: Complex to Re/Im" function, and then store these - either in
    separate files or in adjacent columns/rows in the same file. Then, when
    you read in the data again, use the "Numeric: Re/Im to Complex" function
    to put the two "halves" together.
    If you actually want Excel to interpret the numbers as imaginary, then
    you'll probably want to create a string for each complex number of the
    form "Re + Im*i" (after separating the Re and Im parts), by using
    "String:Format into String" with 2 numeric inputs and the format string
    "%f+%fi".
    Reading the data back into Labview then would require splitting the
    string into the 2 pieces by using "Stringcan from String" with 2
    numeric outputs (smae precision as original numbers specified by the 2
    Default Value inputs) and the same format string "%f+%fi", and then using
    the above-mentioned "Numeric: Re/Im to Complex" function. It worked for
    me, so if you can't follow what I am describing, send me an email and I
    can email you what I did (LV 5.1.1).
    Paul
    Biz wrote:
    > Having trouble converting array to spreadsheet string, storing the
    > file and coverting back to array with complex numbers
    >
    > I am working with a network analyzer. I have arrays made of 5 columns
    > the first consisting of an integer and the next four consisting of
    > complex numbers. I am converting the array into a spreadsheet string
    > and then saving the file using the write characters to a file VI. That
    > seems to work well as when I open the file in Excel all the data is
    > there. However when I try to reverse the process, open file and
    > convert back to array, I loose some of the data. Specifically the
    > imaginary parts of my complex numbers are all going to zero. I have
    > narrowed down the problem to be in the conversion from spreadsheet
    > string to array and vice versa. I think the problem may be with the
    > 'format' input to the VI. I do not have an adequate resource for this
    > so I am not sure what to put in to accomplish my task. Any takers?
    Research Assistant
    School of Physiotherapy, Curtin University of Technology
    Selby Street, Shenton Park, Western Australia, Australia. 6008
    email: [email protected]
    Tel. +61 8 9266 4657 Fax. +61 8 9266 3699
    "Everyone who calls on the name of the Lord will be saved." Romans 10:12
    "For all have sinned and fall short of the glory of God, and are
    justified freely by his grace through the redemption that came by Christ
    Jesus." Romans 3:23-4

  • In Pages document, how do I search for word and view its frequency and page numbers in a sidebar?

    I have a long document and I want to be able to search for certain key words and phrases, and then see how many times they appear in the document and exactly where.  How do I conduct this sort of search and viewing?  In the past, in Pages and Word, I've been able to view my "finds" in a sidebar but I can't figure out how to activate that service anymore.
    Thanks!

    Here is a word frequency concordance Automator Service that works in both versions of Pages. It does not present a page number reference. It is by descending count, and alphabetically, within the repetitive counts as shown in the image here. In any document, you select the text to process, then Menu > Application Name > Services > Frequency. The Service will open TextEdit with the n-pages of scrollable results. It is 16 pt Helvetica Neue for legibility.
    Here is the code:
    on run {input, parameters}
         try
              set mySelection to input as text
              set formatted_result to concordance(mySelection)
              if formatted_result is not null then
                   set textHeading to "Word Frequency List"
                   tell application "TextEdit"
                   activate
                         set NewDoc to make new document with properties {name:"Concordance"}
                         make new paragraph at beginning of text of NewDoc with data textHeading & return
                         make new paragraph at end of text of NewDoc with data formatted_result
                         tell text of NewDoc
                               set font to "Helvetica Neue"
                               set size to 16
                               set color of paragraph 1 to {0, 0, 65535}
                         end tell
                        end tell
              else
                        display dialog with title ¬
                         "No input selected" with icon stop ¬
                          giving up after 15
              end if
         on error errmsg number errnum
                    display alert ¬
                               "AppleScript Error" message errmsg & "[" & errnum & "]" as critical ¬
                                  giving up after 30
         end try
         return input
    end run
    on concordance(mySelection)
    -- Use Ruby to count word frequency and alphabetically sort words
        set rb to ¬
        "selected = String.new\nfreqs = Hash.new(0)\nselected = ARGV.join('  ').gsub(/[,.]/, \"\")\n
         words = selected.split(/[^\\w-]+/)\nwords.each { |word| freqs[word] += 1 }\n
         freqs_sorted = freqs.sort do |a,b|\n\t
         a.last == b.last ? a.first <=> b.first : b.last <=> a.last\nend\n
         freqs_sorted.each { |k,v| printf \"[ %8s ]          %s\", v, k }"
        do shell script "/usr/bin/ruby -e " & rb's quoted form & space & mySelection's quoted form
    end concordance
    Launch /Applications/Automator and choose New Document, then click the Service icon, and then select the Choose button.
    On the left, you will have a list of Libraries from which to choose workflow items. Find Library > Utilities. In the adjacent column, locate the Run Applescript workflow. Click on it, then drag and drop it in the large workflow window to your right.
    At the top, you can select Service receives text in any application. Leave Output replaces selected text unchecked.
    In your Run AppleScript workflow window, you will see AppleScript boilerplate. Click on it and press command+A, then backspace to delete this content. Copy and paste the above code into this Run AppleScript workflow window. Press the Run button in Automator's upper right corner. If (and it should) a TextEdit window pops up, you are good, and you want to press File > Save. A dialog box will pop-up where you can name your Service. I called my Frequency, you may wish to call it something else. Once you have save it, you can exit Automator. Services are deposited in yourlogin directory/Library/Services.
    If you have a Pages document open with text, either select it, or command+a to select the entire document. Now, you select your Service via Pages > Services > Frequency. This will now pop-up a new TextEdit document with the results. If you want to save this new document, you must use option+File to Save as...

Maybe you are looking for