How do I get the first word from a text divided by “.” [duplicate]
How do I get the first word from a text divided by “.” [duplicate]
This question already has an answer here:
Here's an example of what I need:
This is the text: sample.dbo.Productos
And I just want the word: "sample"
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
String sample = str.split("\.")[0];
Where str
is your String
– GBlodgett
Sep 14 '18 at 21:46
String sample = str.split("\.")[0];
str
String
Hint: docs.oracle.com/javase/10/docs/api/java/lang/…
– Jacob G.
Sep 14 '18 at 21:47
@GBlodgett just what I need, thank you so much.
– Vinicio López
Sep 14 '18 at 21:51
1 Answer
1
Quite simply:
String extractFirstWord = yourText.split(".")[0]
String extractFirstWord = yourText.split(".")[0]
Here, yourText = "sample.dbo.Productos";
yourText = "sample.dbo.Productos";
What did you tried?
– Januson
Sep 14 '18 at 21:46