Format an alpha numeric string

Good day all,
I have what i hope to be a simple question. I have a table that i am storing Latitude and longitude in. The current format for each is as an example N432301 for the Latitude and
W0844150 for the Longitude.
I need the output formated to
N-43-23-01 for Latitude
and
W-84-41-50 for Longitude.

GMoney wrote:
Greg,
I ran this using the following:
{code}
with xx as ( select 'N402456' lat, 'W1203926' lon from dual )
select substr(lat,1,1) || '-' || substr(lat,2,2) || '-' || substr(lat,4,2) || '-' || substr(lat,6,2) latitude,
substr(lon,1,1) || '-' || substr(lon,3,2) || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
from xx;
{code}
and the result was :
LATITUDE
LONGITUDE
N-40-24-56
W-20-39-26
which is wrong because in this case the lon was 3 char versus 2 after dropping the '0' from the 084.
That's why I started with "We really need the rules to make sure it's accurate, "
Seriously, if you don't give us good specifics, you can't complain that much if we don't get all your requirements in the first run.
If you confirm that first one is 3 digits, no problem ...
       substr(lon,1,1) || '-' || substr(lon,2,3) || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
if you need to drop the 0 on the previous example (again guessing, because you haven't given any real rules )
       substr(lon,1,1) || '-' || to_char(to_number(substr(lon,2,3)),'fm999') || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
but at this point, Mike's reg exp shenanigans probably work better
lol
[edit]
Just for completeness:
with xx as ( select 'N432301' lat, 'W0844150' lon from dual union all
             select 'N402456'    , 'W1203926'      from dual
select substr(lat,1,1) || '-' || substr(lat,2,2) || '-' || substr(lat,4,2) || '-' || substr(lat,6,2) latitude,
       substr(lon,1,1) || '-' || to_char(to_number(substr(lon,2,3)),'fm999') || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
  from xx;
LATITUDE   LONGITUDE  
N-43-23-01 W-84-41-50 
N-40-24-56 W-120-39-26
2 rows selected.
With great requirements, comes great results.
With poor requirements, comes poor results

Similar Messages

  • How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values?

    How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values? I'm using the Integrator named "Projects - Transaction Import" and a custom Layout created based on the seeded Layout named "Transaction Import - Accounted". Do I need to somehow change my Layout to make the Document accept numerical values instead of requiring alpha-numeric values? I need to be able to populate the Document with a large amount of transactions and cannot feasibly go through every transaction to add the alpha-valued name of the account segment to every segment that requires it. The segments in particular causing the problem are "Expnd Type" and "Organization Name" which are both alpha-numeric and as such contain the segment number and name; I need to be able to only have to enter the Natural Account Number (6-digit number only) and the Organization Number (5-digit number only).

    How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values? I'm using the Integrator named "Projects - Transaction Import" and a custom Layout created based on the seeded Layout named "Transaction Import - Accounted". Do I need to somehow change my Layout to make the Document accept numerical values instead of requiring alpha-numeric values? I need to be able to populate the Document with a large amount of transactions and cannot feasibly go through every transaction to add the alpha-valued name of the account segment to every segment that requires it. The segments in particular causing the problem are "Expnd Type" and "Organization Name" which are both alpha-numeric and as such contain the segment number and name; I need to be able to only have to enter the Natural Account Number (6-digit number only) and the Organization Number (5-digit number only).

  • Check numbers in alpha numeric string

    Hi All
    Is there any direct command or function module which will find numbers in alpha numeric string or it will check that the string contains only numbers ?
    Regards
    Yogesh

    hi,
    data: fvalue(4) type c,
          nvalue(4) type n.
    fvalue = 'ABC1'.
    nvalue = fvalue.
    if fvalue cn nvalue .                                      
    message i000(zz) with 'fvalue contains not Only numbers'.  
    else.                                                      
    message i000(zz) with 'fvalue containsOnly numbers'.       
    endif.                                                     
    Regards,
    Sailaja.

  • Removing Non-numeric characters from Alpha-numeric string

    Hi,
    I have one column in which i have Alpha-numeric data like
    COLUMN X
    +91 (876) 098 6789
    1-567-987-7655
    so on.
    I want to remove Non-numeric characters from above (space,'(',')',+,........)
    i want to write something generic (suppose some function to which i pass the column)
    thanks in advance,
    Mandip

    This variation uses the like operators pattern recognition to remove non alphanumeric characters. It also
    keeps decimals.
    Code Snippet
    CREATE FUNCTION dbo.RemoveChars(@Str varchar(1000))
    RETURNS VARCHAR(1000)
    BEGIN
    declare @NewStr varchar(1000),
    @i int
    set @i = 1
    set @NewStr = ''
    while @i <= len(@str)
    begin
    --grab digits or (| in regex) decimal
    if substring(@str,@i,1) like '%[0-9|.]%'
    begin
    set @NewStr = @NewStr + substring(@str,@i,1)
    end
    else
    begin
    set @NewStr = @NewStr
    end
    set @i = @i + 1
    end
    RETURN Rtrim(Ltrim(@NewStr))
    END
    GO
    Code to validate:
    Code Snippet
    declare @t table(
    TestStr varchar(100)
    insert into @t values ('+91 (8.76) \098 6789');
    insert into @t values ('1-567-987-7655');
    select dbo.RemoveChars(TestStr)
    from @t

  • OT:  Alpha-numeric string after screen-name

    What the heck is this string attached to my screen name??   Only appeared after the forum had timed out and had to log back in again.
    Weird !

    I've emailed you privately about this. It appears you have an identity crisis - at least in cyberspace.
    There are at least three Nadia Perres, all of them you: Nadia Perre plain and simple, Nadia Perre-39BgI8, and Nadia Perre-NuTcRP (the Community Expert). You need to contact JC (or a shrink) to get things sorted out.

  • Randomly Generate alpha-numeric strings?

    Hi, can somebody help me to randomly generate strings such as A1, B5, E 2, etc. The range for the values I need generated are [A-E][1-5]. I looked at lots of code for Random generating numbers, but found nothing related to what I need. I hope somebody can help me out here. Thanks!

    nevermind, i figured it out! thanks anyway

  • Numbers: Text to numerical string - Made easy?

    How can I convert/transform numbers that are in text format to a numerical string, in order to use functions, e.g. SUM, MEAN etc?
    Thanks!
    P.S. I have read the manuals and tried everything "obvious".

    Assuming that your numeric strings are in column B, in cells of column C insert the formula :
    =VALUE(B)
    As it's written in iWork Formulas and Functions User Guide
    The VALUE function returns a number value even if the argument is formatted as
    text. This function is included for compatibility with tables imported from other
    spreadsheet applications.
    So, the values in column C are numeric ones which may be summed as you may see in the footer cell C22
    =SUM(C)
    Yvan KOENIG (VALLAURIS, France) mercredi 17 août 2011 19:45:32
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • Find alpha numeric words with at least 3 words

    Hi,
    I am trying to extract a string which has got ranges like 10-20 or 10A-20 or A10-20 or 20-A40 or 20-40A or A20-30A and so on. besides this I would want to extract a thrid word which would contain a number or alpha numeric string or again a range alpha numeric string.
    for example:
    1. abc 123 12-2a cdf
    2. efg 23-12 345 alksd
    3. klkj; 123 456 asdfg
    from the above examples I have to fetch row 1 & 2
    Please advice.
    Many thanks in advance.
    Edited by: 920390 on Mar 12, 2012 8:57 PM

    920390 wrote:
    Hi,
    I am trying to extract a string which has got ranges like 10-20 or 10A-20 or A10-20 or 20-A40 or 20-40A or A20-30A and so on. besides this I would want to extract a thrid word which would contain a number or alpha numeric string or again a range alpha numeric string.
    for example:
    1. abc 123 12-2a cdf
    2. efg 23-12 345 alksd
    3. klkj; 123 456 asdfg
    from the above examples I have to fetch row 1 & 2
    Please advice.
    Many thanks in advance.
    Edited by: 920390 on Mar 12, 2012 8:57 PMIt is a violation of Third Normal Form to store multiple values in a single column!
    you reap what you sowed!

  • TS3276 I need feedback for the following issue. When I send email from this 27 inch iMac, the computer adds a string of characters in vertical column that represents the QWERTY key board, all alpha numeric characters are included. Yahoo mail, issue only o

    Restating my issue / question...
    When I send email from this iMac, there is a string of characters assigned. The characters are all the "alpha numeric" characters on the QWERTY key board. This only occurs when email is sent from this iMac. The issue does not manifest when using any other lap top or computer.
    Hence, I have ruled out the issue is a yahoo mail matter.
    Again, I can access the Yahoo mail account form multiple devices and send email without unintended assignment of character strings, but when I send wmail using this iMac, the issue happens everytime.
    Characters are stacked verticaly in a column. It looks as if all characters (except function keys) are included in the string.
    Any ideas?
    GMc

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It won’t solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    Third-party system modifications are a common cause of usability problems. By a “system modification,” I mean software that affects the operation of other software — potentially for the worse. The following procedure will help identify which such modifications you've installed. Don’t be alarmed by the complexity of these instructions — they’re easy to carry out and won’t change anything on your Mac. 
    These steps are to be taken while booted in “normal” mode, not in safe mode. If you’re now running in safe mode, reboot as usual before continuing. 
    Below are instructions to enter some UNIX shell commands. The commands are harmless, but they must be entered exactly as given in order to work. If you have doubts about the safety of the procedure suggested here, search this site for other discussions in which it’s been followed without any report of ill effects. 
    Some of the commands will line-wrap or scroll in your browser, but each one is really just a single line, all of which must be selected. You can accomplish this easily by triple-clicking anywhere in the line. The whole line will highlight, and you can then copy it. The headings “Step 1” and so on are not part of the commands. 
    Note: If you have more than one user account, Step 2 must be taken as an administrator. Ordinarily that would be the user created automatically when you booted the system for the first time. The other steps should be taken as the user who has the problem, if different. Most personal Macs have only one user, and in that case this paragraph doesn’t apply. 
    Launch the Terminal application in any of the following ways: 
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.) 
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens. 
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid. 
    When you launch Terminal, a text window will open with a line already in it, ending either in a dollar sign (“$”) or a percent sign (“%”). If you get the percent sign, enter “sh” and press return. You should then get a new line ending in a dollar sign. 
    Step 1 
    Triple-click the line of text below to select it:
    kextstat -kl | awk '!/com\.apple/{printf "%s %s\n", $6, $7}' | open -f -a TextEdit 
    Copy the selected text to the Clipboard by pressing the key combination command-C. Then click anywhere in the Terminal window and paste (command-V). A TextEdit window will open with the output of the command. Post the contents of that window, if any — the text, please, not a screenshot. You can then close the TextEdit window. The title of the window doesn't matter, and you don't need to post that. No typing is involved in this step.
    Step 2 
    Repeat with this line:
    { sudo launchctl list | sed 1d | awk '!/0x|com\.(apple|openssh|vix)|org\.(amav|apac|cups|isc|ntp|postf|x)/{print $3}'; sudo defaults read com.apple.loginwindow LoginHook; } | open -f -a TextEdit 
    This time you'll be prompted for your login password, which you do have to type. Nothing will be displayed when you type it. Type it carefully and then press return. You may get a one-time warning to be careful. Heed that warning, but don't post it. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator. 
    Note: If you don’t have a login password, you’ll need to set one before taking this step. If that’s not possible, skip to the next step. 
    Step 3
    launchctl list | sed 1d | awk '!/0x|com\.apple|org\.(x|openbsd)/{print $3}' | open -f -a TextEdit 
    Step 4
    ls -1A /e*/mach* {,/}L*/{Ad,Compon,Ex,Fram,In,Keyb,La,Mail/Bu,P*P,Priv,Qu,Scripti,Servi,Spo,Sta}* L*/Fonts 2> /dev/null | open -f -a TextEdit  
    Important: If you formerly synchronized with a MobileMe account, your me.com email address may appear in the output of the above command. If so, anonymize it before posting. 
    Step 5
    osascript -e 'tell application "System Events" to get name of every login item' | open -f -a TextEdit 
    Remember, steps 1-5 are all copy-and-paste — no typing, except your password. Also remember to post the output. 
    You can then quit Terminal.

  • Non-numeric String formatting

    Ok, I understand about numeric string formating (NumberFormat). But what I need help with is string formatting.
    For example, I'm working on an app with fixed-length records. Let's take a name field. I need the string "John Doe" formatted to a 40-character field, right-justified. Can someone point me to a class or a URL with information on this.
    Sorry for asking such an elementary question.

    Ok, I understand about numeric string formating
    (NumberFormat). But what I need help with is string
    formatting.
    For example, I'm working on an app with fixed-length
    records. Let's take a name field. I need the string
    "John Doe" formatted to a 40-character field,
    right-justified. Can someone point me to a class or a
    URL with information on this.In the JDK I found nothing, but in the jakarta-Projekt of apache.org:
    http://jakarta.apache.org/commons/lang.html
    There is a class called StringUtils.
    You only have to write:
    String rightJustified = StringUtils.rightPad("John Doe", 40);
    If you don't find something in the JDK look at Jakarta. They have a lot of useful stuff.

  • Removing non-alpha-numeric characters from a string

    How can I remove all non-alpha-numeric characters from a string? (i.e. only alpha-numerics should remain in the string).

    Or even without a loop ?
    Extract from the help for the Search and Replace String function :
    Right-click the Search and Replace String function and select Regular Expression from the shortcut menu to configure the function for advanced regular expression searches and partial match substitution in the replacement string.
    Extract from the for the advanced search options :
    [a-zA-Z0-9] matches any lowercase or uppercase letter or any digit. You also can use a character class to match any character not in a given set by adding a caret (^) to the beginning of the class. For example [^a-zA-Z0-9] matches any character that is not a lowercase or uppercase letter and also not a digit.
    Message Edité par JB le 05-06-2008 01:49 PM
    Attachments:
    Example_VI_BD4.png ‏2 KB

  • Check string for alpha numeric

    is there a direct way to check whether the string is alpha numeric?

    private boolean isAlphaNumeric(String str){
              boolean blnNumeric = false;
              boolean blnAlpha = false;
              char chr[] = null;
              if(str != null)
                   chr = str.toCharArray();
              for(int i=0; i<chr.length; i++){
                   if(chr[i] >= '0' && chr[i] <= '9'){
                        blnNumeric = true;
                        break;
              for(int i=0; i<chr.length; i++){
                   if((chr[i] >= 'A' && chr[i] <= 'Z') || (chr[i] >= 'a' && chr[i] <= 'z')){
                        blnAlpha = true;
                        break;
              return (blnNumeric && blnAlpha);
    Hope this would solve your problem

  • Generating Random Alpha numeric Salt String using MD5 or other algorithm

    Hello,
    I have a requirement where i need to generate a random alpha numeric salt for MD5 algorithm. Is there a best way to generate this salt ?
    The alpha numerics should confine to 5 digits with possible values for each digit being (a-z), (0-9), (A-Z).
    Any good random generator for salt would be appreciated.
    Thanks.

    Hi there,
    I think the book you read is the book "Java Security", I have that one too.
    Please read all those pages before this code.........
    In this code, it used the RSA algorithm to do the encryption and JDK DOES NOT support
    RSA algorithm....
    Beside, this line
    KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA", "BC");It implies the BouncyCastle security provider is in use.... so
    www.bouncycastle.org might be a good place to start with....
    Good luck!

  • BEx report hangs- selecting Alpha numeric values

    I am working on the existing customer report
    customer is the selection parameter for my report.
    Issue is Customer has numerical and alpha numerical values.
    If i give parameter rangs of value is numerical
    01 - 500 query works fine
    01-50cust1
    50 cust1 - 195 cust2
    query hangs.
    Is their any way we can improve the query performance .
    for searching alphanumerica values.
    I have a workbook is built based on the query.
    morethan 6 queries attached in the sheet 1....sheet2
    each sheet has it is own query with values.
    when I refresh and execute the workbook with the customer alphanumerica values it hangs.
    Query is built based on the multiprovider.
    Please help me onthis

    Hello,
    Try exporting in the 'fully formated grids and text'. It shouldl give you the 'member alias' used in the report.
    Looks like if you export in the 'querry ready grids and text' it will show the 'member name' as in database although the report may have used the 'member alias'.
    Regards

  • The entries in "Notes" are shown sorted by date of creation. Can they be sorted alpha/numerically?

    I would like to be able to sort the entries in "Notes" alpha numerically. By default these entries are sorted based on the date of creation of the entry.

    As I said, it works perfectly well for me. Try putting the sidebar into Contact Sheet mode and see if the dates are sorted correctly. Here's an example from my machine:
    As you can see, if you have good eyes, all are arranged in date order, regardless of day, month or year.
    Just two things occur to me about your problem. I see that your date format differs significantly from mine. Try changing it in System Preferences->Language & Text->Formats and see if that has an effect. There may be a bug in regard to how Preview handles the various date formats. You might also try logging into your test account and see if Preview behaves correctly there, with everything in the default state. If you don't have a test account, create one. Leave everything in the default state and keep it around for future tests--it doesn't take much space and is very handy to have around.
    Francine
    Francine
    Schwieder

Maybe you are looking for

  • What setting should I use for Abbey Road drums?  Getting a cpu overload issue

    What setting should I use for Abbey Road drums (i.e. multi-output, stereo, etc)?  Getting a cpu overload issue.  I have a macbook pro, 4 gb ram, running Logic Pro 9.  Just 3 tracks of drums and a few real instrument tracks.  Can't find a guide in the

  • Copying music from mini ipod to computer

    I want to copy the music I have on my ipod nano to a different computer with a fresh copy of itunes 10.1.1.4. I tried the directions I found on the support page; Edit, Preference, check - Copy files to iTunes Media folder when adding library. The iTu

  • WebLogic10.3) starting ManagedServer with nodemanager script

    When I started ManagedServer with script (startManagedWebLogic.sh), it was OK. the script was ./startManagedWebLogic.sh ManagedServer_1 http://xxx.xxx.xxx.xxx:7001 But, the problem is here I used this script to start ManagedServer named as ManagedSer

  • Coordinate system

    I am having trouble getting my local-world-view-screen matrix setup right. First, coordinate system is: +x to the right +y down +z into the screen right? this is what I get from Vector3D class. But now that I am thinking of it DirectX and OpenGL have

  • "You can't open the application iTunes because it is not supported on this type of Mac"

    Yesterday, Software Updater has installed something which required me to "close iTunes in order to complete the installation" - I can only assume it was an iTunes (or related) update? Now when I try to open iTunes, a window appears, stating: "you can