Regular expression for song name in android [closed] - android

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
In my application I want to display the song's name. Now it is showing the entire song path, like this
String song_name = /storage/Music/Lean on.mp3
but I want to display only the song's name, that means
String song_name = Lean on.mp3
Can any one help me with the regular expressions used for extracting the name of song from the file path?

You can use subString function with combination of LastInedexOf function.
please find below example
String path=":/storage/Music/Lean on.mp3";
String filename=path.substring(path.lastIndexOf("/")+1);

Related

Again N Again Split the string with "#" [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I want to split the String with the # symbol
'#Happy#sad#Angry#Tear and so on`
I don't know how many times user enters hashtags so how can I split that String?
I tried this:
allhashtag= String.valueOf(edt_hashtag.getText());
String tag1[] =allhashtag.split("#");
String tag2= tag1[0];
Try for loop for split String when we don't know how many characters in String
Try this code:
String s = allhashtag;
if(s.toString().contains("#"))
{
String tags[]=s.toString().split("#");
for (String tag : tags)
{
Log.e("tag",""+tag);
}
}

search text in a website programmatically [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
i want my app to search a specific website(from an url) for a specific text and give me the 3 chars after that text or to search for a pattern with a placeholder and give me the first matching string. Is that possible? There is no need to display the website.
Once you download the page using something like HTTPUrlConnection, you can use a regex with your search term
Pattern p = Pattern.compile("specific text(\w\w\w)");
Matcher m = p.matcher(site_text);
boolean b = m.matches();
The three \w will be captured in a group for you to use if there's a match.

how do i user pattern matches like search engine [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to generate Search Suggestions that matches the input in the AutoCompleteTextView.
It will check for the matches for the first word I type then all the related words should be populated.
After I type next character then it will match combination of that word and populate the result .
I do not understand how to do pattern matches.
For example: Suppose, there are three country names.
INDIA, IRAQ, IRAN.
When I type I then I want get All Country names Starting with I to be displayed.
When I type IR then result should be IRAN,IRAQ. ETC.
Your requirement will be satisfied in AutoCompleteTextView itself.
Threshold is used to set from the length where auto complete show it's suggestion:
For ex:
String[] languages={"INDIA", "IRAQ","IRAN"};
AutoCompleteTextView text(AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,languages);
text.setAdapter(adapter);
text.setThreshold(1);

How do I return an int from EditText and than show that number in Toast? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am a beginner at programming Android, please help with this simple project.
I want an integer to show up in toast, which I write in textBox. I do not know what to put in the highlighted part here.
Sorry for the link, but I cannot post the picture
You need to use the getText() method to get the text the user entered.
Change the myEdit declaration to:
final EditText myEdit = ... ;
and then use:
Toast.makeText(MainActivity.this, myEdit.getText().toString(), ...

adding string as integer [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
in my application i have got 0.00 in edit text.next when i enter 2or3 or any digit its getting concat with 0.00 and getting 0.003.
if(item.equals("0.00")){
item=item+string;}
i changed the code.but this time too its getting an error
if(item.equals("0.00")){
int a=Integer.parseInt(item.toString());
int b=Integer.parseInt(string.toString());
int c=a+b;
item=String.valueOf(c);}
If you are using decimal places then you will want to use a data type that supports those, such as double. Try this:
double d = Double.parseDouble(item.toString());
NOTE: If both your variables are of string type, then you won't need to use toString()
You want O.OO but still using Integer. Try using FLOAT.
Also, FLOAT is NEVER a perfect value. So you might have .XX added.
You have an error, because "0.00" has decimal places, so it is parsed as a floating point number, not integer.
Parse it as a double:
String item = "0.00";
double result = Double.parseDouble(item) + 0.03; // result is 0.03

Categories

Resources