SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    convert 2 characters

    Please help:
    I would like to create a program which converts some letters into different ones. Here is the idea.
    1) I want 2 text areas (input and output) + "convert" button
    2) if I type in the input area the letters "ea" I would like it to be converted into "a", so that If I type "cambrea" and press "submit" the output text will have "cambra".
    3) if I type "e " which is (e+space) I want it to be converted into " " which is "space" example: if I type the word "spine " it should be converted into "spin , note that there is a space after "spin ".
    4) If I type any vowel before "o" it should render "o", example: gambuo becomes gambo.
    would this be possible? I'm not very familiar with Javascript even though I can modify it. I hope someone can help. It will make a big difference.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,713
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Regular expressions are possibly what you're after.

    You can then use a regular expression with the the replace method to achieve the replacements that you're after. You can also use straight string replacement too.

    Is this for a course that you're taking? Or is there some data-set that needs to be converted. If the latter, we should be able to help you find pre-existing solutions that already exist in the wild.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •