Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Extract the first word (before the , )

Posted on 2016-11-29
2
Medium Priority
?
87 Views
Last Modified: 2016-11-29
Hi All,

I need to extract from a list below only the first word. Data is a little tricky, in few lines, there is no space after the first comma. Using Oracle 11g.

BOLT, ELEVATOR: 5/16", 2"LG, UNC, BLACK, 100
CAPSCREW, SOCKET HEAD: 10-32, 3/8"LG, 8, FLAT, PKG QTY = 100
CAPSCREW, SOCKET HEAD: 10-32, 1"LG, PLATED, 8, FLAT, 100
CAPSCREW,SOCKET HEAD: 1/4", 28, 1/2"LG, PLATED, 8, FLAT, 100
CAPSCREW,FLAT SOCKET HEAD:1/4"-28, 3/4"LG, GR8,COUNTERSUNK, PKG QTY = 100
SCREW,SHEET METAL: #10 X 3/8", PLATED, BINDING, ROBERTSON, GIMLET POINT, PKG QT

Thanks
0
Comment
Question by:mohammadzahid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 41906604
Try regular expression

Regexp_substr(line, '\w[^,]', 1, 1)
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 41906605
Try this:
select regexp_substr(some_column,'^[^,]*') from some_table;
or
select substr(some_column,1,instr(some_column,',')-1) from some_table;
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to take different types of Oracle backups using RMAN.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question