Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Extracting Value from a String that contains key value pairs
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Extracting Value from a String that contains key value pairs // ____ _ __ ____ ____ // | _ \ | |/ / |___ \ | _ \ // | |_) | | ' / __) | | | | | // | _ < | . \ / __/ | |_| | // |_| \_\ |_|\_\ |_____| |____/ // //By <Broken Committee> import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { String variables = "abcd=32434, xxxx=23423, yyy=234234, zzz=23423"; String[] details = variables.split(","); for (int x=0;x<details.length;x++) { String[] d = details[x].split("="); if(d.length == 2) { String key = d[0]; String val = d[1]; if(key.equals("yyy")) { System.out.println("Value found:"+val); } } } } }
[
+
]
Show input
edit mode
|
history
|
discussion