how to separate no and text in java
Java
String input = "C3H20IO";
List<String> array1 = new ArrayList<String>();
List<Integer> array2 = new ArrayList<Integer>();
Pattern pattern = Pattern.compile("([A-Z][a-z]*)([0-9]*)");
Matcher matcher = pattern.matcher(input);
while(matcher.find()){
array1.add(matcher.group(1));
String atomAmount = matcher.group(2);
int atomAmountInt = 1;
if((atomAmount != null) && (!atomAmount.isEmpty())){
atomAmountInt = Integer.valueOf(atomAmount);
}
array2.add(atomAmountInt);
}
Also in Java:
- Title
- create object of static class in java
- Category
- Java
- Title
- java output length of each line in a text document
- Category
- Java
- Title
- read integer input java
- Category
- Java
- Title
- méthode retourne nom classe java
- Category
- Java
- Title
- how to make a char uppercase in java
- Category
- Java
- Title
- sdkmanager JAVA_HOME invalid directory
- Category
- Java
- Title
- count occurrences of character in string java 8
- Category
- Java
- Title
- how timer class and display to jtextfield w3schools in java
- Category
- Java
- Title
- how to scan a character in java
- Category
- Java
- Title
- java string array to arraylist
- Category
- Java
- Title
- get raondom from array java
- Category
- Java
- Title
- java exceptions for catch
- Category
- Java
- Title
- get certain character from string java
- Category
- Java
- Title
- android hide and show bottom navigation
- Category
- Java
- Title
- read csv java
- Category
- Java
- Title
- reverse a string in java
- Category
- Java
- Title
- validate isbn number java
- Category
- Java
- Title
- remove space string java
- Category
- Java
- Title
- how to echo java_home in windows cmd
- Category
- Java
- Title
- Unrecognized option: --version Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
- Category
- Java
- Title
- java go troght loop object
- Category
- Java
- Title
- java vs javascript
- Category
- Java
- Title
- how to push an element in hashset java
- Category
- Java
- Title
- calculate days between two dates in java
- Category
- Java
- Title
- java random integer
- Category
- Java
- Title
- how to do substring java
- Category
- Java
- Title
- what it means when create final variable in java
- Category
- Java
- Title
- java convert a set to array
- Category
- Java
- Title
- Write a JAVA method that expands a given binomial (ax + by)n, where integers a, b, n are user inputs. For example, if a = 2, b = -12, n = 4 are entered the method should print or return
- Category
- Java
- Title
- convert string to localdatetime
- Category
- Java
- Title
- java divisible by operator
- Category
- Java
- Title
- spigot custom join message
- Category
- Java
- Title
- java if
- Category
- Java
- Title
- abstraction in java
- Category
- Java
- Title
- java how to print a string[]
- Category
- Java
- Title
- Error executing Maven. java.io.FileNotFoundException: The specified user settings file does not exist: /etc/java-8-openjdk
- Category
- Java
- Title
- java min function
- Category
- Java
- Title
- boolean checkbox swing
- Category
- Java
- Title
- double round java integer
- Category
- Java
- Title
- pascals triangle java
- Category
- Java
- Title
- get drawable with string android java
- Category
- Java
- Title
- java variable declaration
- Category
- Java
- Title
- java string format .2f
- Category
- Java
- Title
- java regex replace all characters before
- Category
- Java
- Title
- java cannot find file path
- Category
- Java
- Title
- binary string to int java
- Category
- Java
- Title
- javafx fill tableview with data
- Category
- Java
- Title
- even or odd in java
- Category
- Java
- Title
- bootstrap alert
- Category
- Java
- Title
- read csv in java in spring
- Category
- Java
- Title
- set java
- Category
- Java
- Title
- JavaFX mouse over effe
- Category
- Java
- Title
- bukkit java set leather armor color from hex
- Category
- Java
- Title
- login and logout react native and firebase
- Category
- Java
- Title
- double parse jtextfield
- Category
- Java
- Title
- getindexrequest elasticsearch
- Category
- Java
- Title
- get number of items in arraylist java
- Category
- Java
- Title
- how to return the lower of two values in one line java
- Category
- Java
- Title
- java map foreach
- Category
- Java
- Title
- transformer un string en double java
- Category
- Java
- Title
- boolean java.lang.String.equals(java.lang.Object)' on a null object reference
- Category
- Java
- Title
- java create txt file
- Category
- Java
- Title
- fibonacci sequence in java recursion
- Category
- Java
- Title
- java foreach map
- Category
- Java
- Title
- processing pi
- Category
- Java
- Title
- string to char in java
- Category
- Java
- Title
- taking string input in java
- Category
- Java
- Title
- properties java 8 maven in pom xml
- Category
- Java
- Title
- what is a variable in java
- Category
- Java
- Title
- find first non repeating character in a string
- Category
- Java
- Title
- find a substring in a string java
- Category
- Java
- Title
- remove action bar android studio
- Category
- Java
- Title
- bukkit register commands
- Category
- Java
- Title
- error attribute fabattached not found
- Category
- Java
- Title
- java map iteration
- Category
- Java
- Title
- how to check internet is working or not in java
- Category
- Java
- Title
- tower of hanoi program in java using recursion
- Category
- Java
- Title
- python vs java
- Category
- Java
- Title
- Spring Security JWT Authentication + PostgreSQL – RestAPIs SpringBoot + Spring MVC + Spring JPA
- Category
- Java
- Title
- Java int to roman
- Category
- Java
- Title
- java instantiate collection with values
- Category
- Java
- Title
- 2d array length in java
- Category
- Java
- Title
- reading string after double in java
- Category
- Java
- Title
- java create unmodifiable list
- Category
- Java
- Title
- generate objects with for loop java
- Category
- Java
- Title
- How to make a class in Java?
- Category
- Java
- Title
- java replace all html tags
- Category
- Java
- Title
- loop and save letters in a string java
- Category
- Java
- Title
- import java.util.*;
- Category
- Java
- Title
- setting up javafx in eclipse
- Category
- Java
- Title
- java 8 find min value in array
- Category
- Java
- Title
- java iterator example
- Category
- Java
- Title
- can we overload a static method in java
- Category
- Java
- Title
- diagonal difference hackerrank solution in java 8 using list
- Category
- Java
- Title
- java sql question mark
- Category
- Java
- Title
- how to show the hex detail of a file in java
- Category
- Java
- Title
- how to limit double decimal places java
- Category
- Java
- Title
- java letter alphabet index
- Category
- Java
- Title
- how to change maven java version in po,
- Category
- Java
- Title
- string reverse in java
- Category
- Java