Last active
November 24, 2018 14:58
-
-
Save javatlacati/ab28a67c4b4fbee3f1beeb39e6116279 to your computer and use it in GitHub Desktop.
Extractor de números en Dukescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dew.demo.ko4j; | |
import net.java.html.json.*; | |
import java.util.regex.*; | |
import java.util.*; | |
@Model(targetId="", className="ExtractorDeNumeros", properties={ | |
@Property(name="cadena", type=String.class) | |
}) | |
class Extractor { | |
@ComputedProperty | |
public static List<Integer> extraerNumeros(String cadena) { | |
// aca los vamos a guardar uwu | |
List<Integer> todosLosNumeros = new ArrayList<Integer>(); | |
// un encuentrador vrgs :v | |
Matcher encuentrador = Pattern.compile("\\d+").matcher(cadena); | |
// busca prro >:v | |
while (encuentrador.find()) { | |
// me lo guardas porfis? | |
todosLosNumeros.add(Integer.parseInt(encuentrador.group())); | |
} | |
// sale bai :'v | |
return todosLosNumeros; | |
} | |
public static void main(String... args) { | |
ExtractorDeNumeros model = new ExtractorDeNumeros("Metros de tierras en Valencia y precio: 500, 10000."); | |
model.applyBindings(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1 data-bind="text: cadena">Say something</h1> | |
<textArea data-bind="textInput:cadena"></textArea> | |
<label>valores hallados</label> | |
<ul data-bind="foreach: extraerNumeros"> | |
<li> | |
<p data-bind="text: $data"></p> | |
</li> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment