#replaceall
Explore tagged Tumblr posts
Text
replaceAll() y replaceWith()
Sustituir Elementos en jQuery. Introducción En el desarrollo web, la capacidad de sustituir elementos del DOM de manera dinámica es esencial para crear interfaces interactivas y fluidas. jQuery, una biblioteca JavaScript altamente popular, ofrece dos métodos poderosos para sustituir elementos: replaceAll() y replaceWith(). Estos métodos permiten a los desarrolladores reemplazar elementos…
#desarrollo web#HTML#Interfaces Interactivas#Javascript#jquery#Manipulación del DOM#Programación Web.#replaceAll#replaceWith#Sustituir Elementos
2 notes
·
View notes
Text
Esta funcion nos permite obtener una salida de reemplazo para aplicarlo en una funccion para eso. Es dificil de resumirlo, para enttenderlo deben ver el post. Espero les sea de utilidad y ahora si pero ahora si tengan un buen finde!
0 notes
Text
.08 | Dados personalizados
Los dados de Foroactivo, los usamos, los odiamos por la mala suerte que tenemos con el RNG, pero también odiamos su estilo ¿verdad?... ¿VERDAD? Bueno, hace un tiempo @mrd-design hizo un tutorial para editar su estilo. Este daba un código bastante largo, pero muy completo para editarlo... Pero en su momento, me pareció complicado y en su lugar, en mi foro yo había "ideado" otra manera.
No se si llamar a esto algo "bien hecho", es solo un truco que se me ocurrió en aquella época y que a mi me dio resultado, porque pude poner el estilo de los dados como yo quería. Hoy lo revisaba, y tras hacerle algunas "correcciones", se los comparto por si les sirve.
El código es simple. Es solo un código para reemplazar palabras. Lo que hice fue buscar palabras clave dentro del lanzamiento de los dados, como "el miembro X ha lanzado bla bla bla..." y ejecuté un "replaceall" para que, en lugar de anunciar esa frase, ponga un div. Así fui buscando más palabras que me ayudasen a cerrar esos divs, y finalmente creé un a tablilla sencilla para el lanzamiento de los dados.
Lo primero que vas a hacer es tomar los posts, para no cambiar, romper o alterar nada de los demás posts o de la estructura del foro. Lo que tienen que hacer es ir a los templates, ahí buscar viewtopic_body y en este template, buscan la siguiente línea:
Si todavía no editaste el template, esa línea es la 188, pero sabemos que ya le metiste mano hasta el cansancio, así que te tocará buscarla. Ahora ¿ves que resalta "lotus"? Bueno, "lotus" es solo un class que creé para poder usarlo como identificador para el script que vamos a usar para los dados... que es este:
https://pastebin.com/yj7vdk6A (182)
Y ahora vas a ir a Módulos » Gestión de los códigos Javascript. Y ahí vas a crear uno nuevo, lo vas a poner para que se muestre en los temas y vas a pegar el código de arriba.
Si todo salió bien, tu próximo lanzamiento de dados debería haberse modificado y ahora se tendría que ver de la siguiente manera:
Como ves, la tirada de dados ahora crea divs, esos divs no estarán en el post, pero se pueden editar dándoles estilo desde el CSS de tu foro. Es solo un truco sencillo, pero si a alguien le sirve, lo comparto con gusto.
Dicho esto, tal vez a alguien le resulte un código muy precario o torpe, pero hasta ahora, desde que lo empecé a usar, no me rompió nada en el foro y me ha dado resultados. Los leo si tienen alguna duda, saludos!
No tengo donde poner créditos en este código, pero agradecería que si lo usas, pongas el link a mi tumblr en cualquier rinconcito de créditos o agradecimientos que tengas en tu foro.
Por último, no es obligatorio, no es necesario si no quieren. Pero si gustan, tengo un ko-fi para recibir una propina de aquellos que quieran y puedan. Aunque como digo, no es condición de nada. Todos reciben de mi parte el mismo trato <3
@elalmacen-rp
28 notes
·
View notes
Text
AndroidTale pt3
Well, if they sent this menance to us...what say we send it back and see how they like it.
*goes to the kill code* and
replaceAll("monster", "human");
Haha also, since their eyes work as cameras to detect monsters. I think itll be really funny if FR1-SK got really confused at some.
"Should...should I attack just in case???"
9 notes
·
View notes
Text
can't imagine this will be useful for anyone, but... my updated browser version api support notes:
sticky thead: firefox 59, chrome 91 es2020 ?. : firefox 74, chrome 80 ''.replaceAll(): firefox 77, chrome 85 regex lookbehind: firefox 78, chrome 62
MacOS 10.11 (~2008 Macs): Firefox 78; Chrome 103
es2021 ??= : firefox 79, chrome 85 overflow:clip: firefox 81, chrome 90 not(a, b): firefox 84, chrome 88 top-level await: firefox 89, chrome 89 dynamic import in content script: firefox 89, chrome ???? [].at(): firefox 90, chrome 92
avif images: firefox 93, chrome 85 storage.local.onChanged.addListener: firefox 101, chrome 73 mv2 scripting api: firefox 102 pale moon is firefox 102 mv2 non-persistent background page: firefox 106 mv3 basic support: firefox 109, chrome 88 [].findLast: firefox 104, chrome 97 manifest.json gecko_android: firefox 113 module workers: firefox 114, chrome 80 link rel=modulepreload: firefox 115, chrome 66
MacOS 10.12 (2009-2010): Firefox 115; Chrome 103
media query range: firefox 63, chrome 104
Windows 7/8: Firefox 115; Chrome 109
[].toSorted(): firefox 115, chrome 110 non-buggy image-set: firefox 113, chrome 113 color-mix: firefox 113, chrome 111
MacOS 10.13 (2009-2010): Firefox 115; Chrome 116
object.groupby: firefox 119, chrome 117 css &: firefox 117, chrome 120? css masks: firefox 53, chrome 120 permissions.request: fenix 120? :has(): firefox 121, chrome 105 mv3 service_worker and scripts: firefox 121, chrome 121
css color from: firefox 128, chrome 119? mv3 optional_host_permissions, many fixes: firefox 128, chrome 102 mv3 world: "MAIN": firefox 128, chrome 102 mv3 world: "MAIN" (in manifest): firefox 128, chrome 111
most firefox forks: Firefox 128
1 note
·
View note
Note
Oh and basically the same two lines in javascript, so you could do this in you web browser dev console right now without downloading python:
let text = "The text you want to blast" text.replaceAll(/[^ATCGatcg\W_]/g,"").replaceAll(/\s+/g, " ")
WHAT DO YOU MEAN YOU'RE DOING IT ALL BY HAND??? LIKE BACKSPACING OUT EVERY LETTER BEFORE YOU SEARCH THE STRING???
String identified: AT A ' G T A A??? ACACG T TT AC T TG???
Closest match: Crassostrea gigas strain QD chromosome 2 Common name: Pacific oyster

18K notes
·
View notes
Text
It took me a while to figure out why LSP was reporting describe was not a valid method of string.
const id = label.toLowerCase().replaceAll(' ', '-'). describe('DisabledField', () => {
0 notes
Text
JavaScript 2021 – New Features – Part 1
ECMAScript 2021(ES12) : New CapabilitiesThe String replaceAll() function The replaceAll() function is available on a string object. The replaceAll() function replaces occurances of a given string in the given string object and returns a new string object. let str = “Namaste Javascript”; let str2 = str.replaceAll(“Java”, “Javascript”); console.log(str2); console.log(str); str = “Namaste Namaste Namaste”; console.log(str.replaceAll(“Namaste”, […] The post JavaScript 2021 – New Features – Part 1 appeared first on TECH - WEB DEVELOPMENT NEWS. https://tech-webdevelopment.news-6.com/javascript-2021-new-features-part-1/
0 notes
Text
Mask Phone Numbers with java
Mask Phone Numbers example give how to mask phone numbers using replaceAll in Java. It also shows how to mask starting of few digits with the # (Hash) of the phone numbers. here we are assuming that we want to display the last 4 digits out of 10.The rest of the number need to be displayed as an #.
for more details please find below link:-
1 note
·
View note
Text
Esta funcion reemplaza el patron de coincidencias con otro elemento pero solo lo hara con la primer coincidencia, omitiendo al resto. Espero les sea de utilidad!
0 notes
Text






4 different ways of removing spaces from a string, sorted by cleanliness.
The replaceAll() method was introduced in ES2021 and I feel it is still underused because many still don’t know about its existence. The last 2 are for educational purposes, they work but we should prefer the replaceAll() or replace() methods for this type of operation.
If you have any topic that you would like me to cover please leave a comment. And, remember to have fun playing with JS! 👍
#100daysofcode#codingbootcamp#codingchallenge#codingdays#frontenddev#html#javascript#javascript30#javascriptbasics#javascriptcode#javascriptdev#javascriptdeveloper#javascriptdevelopers#javascriptengineer#javascriptlearning#javascriptlover#javascripttutorial#learnjavascript#nodejs#programmerlife#softwaredevelopment#webdeveloper#webdevelopment#webproject#javascript_love#developer#codingproblems#codingisfun#programming
2 notes
·
View notes
Text
So, as I mentioned yesterday, I have nearly completed what I set out to do in Ghost Trick, with just two three notable exceptions. I am currently 50-50 on whether to release what I have now, or keep working at it until I solve these last two little problems so it feels more complete. Spoilery details below cut.
I’m going to first go over my process, and then at the bottom I’ll include links and specific details.
Export all .en.xml files using CrystalTile2 and decompress them using BatchLZ77. Copy all of the decompressed files to a different folder that will be used for scripting.
Run a script that mass replaces all hex codes pointing to Sissel’s human/ghost talk sprites, and point them to the cat. Run this on all .en.xml files and save them in a folder.
Run a separate script that only replaces Sissel’s ghost talk sprites, and point it to the cat. Also run this on all .en.xml files and save them in a separate folder.
Sort by “modified date” on all the files. Files that were unchanged by these scripts will have an older modified date so the ones that were edited will be sorted on top.
Compress and re-insert all files edited with the mass replace script. This works for the vast majority of the game. (Yomiel has his own codes for the same sprites, so in scenes that feature both characters this script will only transform Sissel. However, in the endgame once Sissel uses the blue ghost sprite, there are scenes where these codes are used for Yomiel instead; so this script turns Yomiel into a cat in those cases.)
Compress and re-insert all edited files using the ghost-only replacement script. This theoretically fixes all of the endgame issues as it will leave Yomiel alone and only change Sissel.
One exception I found: st13_game022 is caught by the “replace all” script as it replaces Yomiel, but Sissel is not in the scene so it wasn’t reverted. Manually reverted this scene to an unedited state. Have not determined if there are others.
THEORETICALLY, this should do it. I need to playtest today and see if any other weird outlier cases got missed.
However, despite all this, there are two three cases that are still unedited:
Sissel’s entry in the “People” log book.
The “rewind time” screen.
(Newly found): the “can’t access this phone line” screen.
I don’t know where these sprites are defined but they don’t appear to be in any of the scene.en.xml files, because I’ve replaced all of those. I’m hoping they’re also indicated per-localization so I can implement “Cat Mode” as a language selection; if not I’ll need to come up with something else.
My current focus is just making sure all the scenes are correct, and then I’ll see if I can hunt down where those other pointers live. I am very close to a release.
TOOL USED: XVI32, a free hex editor that has support for scripting to mass edit files. This tool saved my life.
The scripts I used for my edits are as follows:
Script to replace all:
ADR 0 REPLACEALL 08 FF 27 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 29 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 2B 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 2D 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 2F 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 31 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 34 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 36 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 38 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 3A 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 28 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 08 FF 2A 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 08 FF 2C 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 08 FF 2E 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 08 FF 30 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 08 FF 32 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 08 FF 35 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 08 FF 37 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 08 FF 39 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 08 FF 3B 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 19 FF 27 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 29 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 2B 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 2D 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 2F 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 31 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 34 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 36 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 38 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 3A 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 28 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 19 FF 2A 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 19 FF 2C 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 19 FF 2E 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 19 FF 30 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 19 FF 32 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 19 FF 35 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 19 FF 37 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 19 FF 39 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 19 FF 3B 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 1B FF 01 00 BY 1B FF 08 00
Script to replace only ghost:
ADR 0 REPLACEALL 08 FF 31 00 BY 08 FF 3C 00 ADR 0 REPLACEALL 08 FF 32 00 BY 08 FF 3D 00 ADR 0 REPLACEALL 19 FF 31 00 BY 19 FF 3C 00 ADR 0 REPLACEALL 19 FF 32 00 BY 19 FF 3D 00 ADR 0 REPLACEALL 1B FF 0D 00 BY 1B FF 08 00
These are typed up in XVI32′s built-in script tool and saved as a “.xsc” file, then to actually run them, I moved all of the scripts and the decompressed files to the same folder as XVI32 and ran the following in an elevated command prompt:
cd [directory where XVI32.exe lives, e.g. c:\users\username\downloads\xvi32] FOR %f IN (*.decompressed) DO START /W xvi32.exe %f /S=scriptname.xsc
There are prettier ways to do it without having everything in one folder but whatever, it worked. At any rate I am going to playtest and see if any scenes are off, and if it looks good, either see if I can figure out the last 2 or just release a janky version 1 anyway. TBD!
1 note
·
View note
Text
incomplete (i.e. not reliable) "convert double-newline-separators into paragraphs" snippet.
parsing and editing HTML properly is really annoying. I'm not actually sure if there's an easy way to do this even if you use a library to go down to HAST or something.
(() => { const rows = $0; const paragraphs = [...rows.querySelectorAll('p')]; paragraphs.forEach((p) => { p.normalize(); const html = p.innerHTML .replaceAll(/<em>(\s+)/g, '$1<em>') .replaceAll(/(\s+)<\/em>/g, '</em>$1') .replaceAll(/<strong>(\s+)/g, '$1<strong>') .replaceAll(/(\s+)<\/strong>/g, '</strong>$1'); if (true /* || html.length > 3000 */) { const fragments = html.split('\n\n'); try { p.replaceWith( ...fragments.map((text) => { const newP = document.createElement('p'); newP.innerHTML = text; if (newP.innerHTML !== text) { console.error(text); // throw new Error(); } return newP; }) ); } catch {} } }); })();
0 notes
Photo
Well played pal but Doesn’t replaceAll() uses loop internally?
144 notes
·
View notes
Link
There are times when we do not know the exact item but we know how it looks like i.e. it has specific pattern and certain characteristics. So by just knowing the pattern, we can identify the items. In the same way, there are patterns to identify strings or set of strings in given text or file in java. For that, we have a REGULAR EXPRESSION in java. e.g. if we want to catch all email from the given text, we know how emails look like so we can define a pattern. We create a regex to represent that pattern. And performing pattern match on the given text, we can list all the emails in the given input text.
So regular expression is a special sequence of character that helps to match, find, edit other string or set of strings in the given input, using a specialized string held in so-called Pattern. The regular expression in java is provided through java.util.regex package. Java.util.regex primarily contains three classes name listed below
- Pattern Class: It is used to define the patterns for matching. An object of Pattern class represents a compiled representation of the regular expression. There is no public constructor available to create an object of Pattern class. To instantiate an object of Pattern class, one has to use any version of public static compile() method of Pattern class. These methods accept regular expression string as the first argument.
- Matcher Class: Matcher class is an engine to interpret the pattern of regular expression and performs the match on the input string. Matcher class too does not have any public constructor. To obtain an object of Matcher class, one has to use call matcher() method on Pattern Class object.
- PatternSyntaxException Class: A PatternSyntaxException class represents an unchecked exception that indicates a Syntax error in the regular expression.
CAPTURING GROUP in Regular Expression
The capturing group represents the group of the letter put together as a single unit. They are created by putting letters to be grouped in parentheses. e.g. (techie360).
Capturing groups are numbered by counting the opening parentheses from left to right. e.g ((t)(pq)) has capturing group in the order ((t)(pq)), (t), (pq).
To find the number of capturing group in the regular expression, just use groupCount() method on Matcher class object. Every capturing group contains group 0 which is not included in the count returned by groupCount().
Example of Capturing Group usage
import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexMatches { public static void main( String args[] ) { // input String String line = "you are reading post on techie360!"; String pattern = "(.*)(\\d+)(.*)"; // Create a Pattern object Pattern p = Pattern.compile(pattern); // Now create matcher object. Matcher m = p.matcher(line); if (m.find( )) { System.out.println("Found value: " + m.group(0) ); System.out.println("Found value: " + m.group(1) ); System.out.println("Found value: " + m.group(2) ); }else { System.out.println("NO MATCH"); } } }
The output of the above program would be
Found value: you are reading post on techie360! Found value: you are reading post on techie360! Found value: 0
REGULAR EXPRESSION SYNTAX AND MEANING
In the below table, a complete list of regular expression letters are listed
Regex Meaning ^ Matches the beginning of the line. $ Matches the end of the line. . Matches any single character except a newline. Using m option allows it to match the newline as well. [...] Matches any single character in brackets. [^...] Matches any single character not in brackets. \A Beginning of the entire string. \z End of the entire string. \Z End of the entire string except for allowable final line terminator. re* Matches 0 or more occurrences of the preceding expression. re+ Matches 1 or more of the previous thing. re? Matches 0 or 1 occurrence of the preceding expression. re{ n} Matches exactly n number of occurrences of the preceding expression. re{ n,} Matches n or more occurrences of the preceding expression. re{ n, m} Matches at least n and at most m occurrences of the preceding expression. a| b Matches either a or b. (re) Groups regular expressions and remembers the matched text. (?: re) Groups regular expressions without remembering the matched text. (?> re) Matches the independent pattern without backtracking. \w Matches the word characters. \W Matches the nonword characters. \s Matches the whitespace. Equivalent to [\t\n\r\f]. \S Matches the non-whitespace. \d Matches the digits. Equivalent to [0-9]. \D Matches the non-digits. \A Matches the beginning of the string. \Z Matches the end of the string. If a newline exists, it matches just before newline. \z Matches the end of the string. \G Matches the point where the last match finished. \n Back-reference to capture group number "n". \b Matches the word boundaries when outside the brackets. Matches the backspace (0x08) when inside the brackets. \B Matches the nonword boundaries. \n, \t, etc. Matches newlines, carriage returns, tabs, etc. \Q Escape (quote) all characters up to \E. \E Ends quoting begun with \Q.
METHODS OF MATCHER CLASS
Matcher class methods can be divided into three categories basis the function they perform:
- Index Methods: index methods provide the index of match found in the input string. Below is the list of index methods:
Method Explanation public int start() Returns the start index of the previous match. public int start(int group) Returns the start index of the subsequence captured by the given group during the previous match operation. public int end() Returns the offset after the last character matched. public int end(int group) Returns the offset after the last character of the subsequence captured by the given group during the previous match operation.
- Study Methods: these methods perform match on the input string and return whether the match is found or not. Please see below list for all Study methods:
Method Description Public boolean lookingAt() Attempts to match the input sequence, starting at the beginning of the region, against the pattern. public boolean find() Attempts to find the next subsequence of the input sequence that matches the pattern. public boolean find(int start) Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index. public boolean matches() Attempts to match the entire region against the pattern.
REPLACEMENT METHODS:
These methods perform replacement in the input string. Below are replacement methods
Method & Description public Matcher appendReplacement(StringBuffer sb, String replacement) Implements a non-terminal append-and-replace step. public StringBuffer appendTail(StringBuffer sb) Implements a terminal append-and-replace step. public String replaceAll(String replacement) Replaces every subsequence of the input sequence that matches the pattern with the given replacement string. public String replaceFirst(String replacement) Replaces the first subsequence of the input sequence that matches the pattern with the given replacement string. public static String quoteReplacement(String s) Returns a literal replacement String for the specified String. This method produces a String that will work as a literal replacement s in the appendReplacement method of the Matcher class.
matches() and lookingAt() methods: Similarity and differences
- both methods match pattern in the input string
- both start matching at the start of input string
- matches() requires complete string to be matched but lookingAt() does not require the complete string to be matching.
To demonstrate the difference see the example below:
import java.util.regex.Pattern; import java.util.regex.Matcher; public class RegexMatches { private static final String REGEX = "too"; private static final String INPUT = "tooo"; private static Pattern pattern; private static Matcher matcher; public static void main( String args[] ) { pattern = Pattern.compile(REGEX); matcher = pattern.matcher(INPUT); System.out.println("REGEX is: "+REGEX); System.out.println("INPUT is: "+INPUT); System.out.println("lookingAt(): "+matcher.lookingAt()); System.out.println("matches(): "+matcher.matches()); } }
the output of the above program
REGEX is: foo INPUT is: fooooooooooooooooo lookingAt(): true matches(): false
- replaceFirst( ) replaces first matching occurrence and replaceAll() replaces all occurrences of the pattern matching.
So we understand how we can use regular expression in java for pattern matching. Regular expressions are quite a powerful tool in java to find, edit and replace the input string.
Hope you enjoyed the article, please share and subscribe to the latest article update.
#regular expression in java#regex in java#java regex#regex usages#pattern matching in java#regex keywords in java#practical usage of regex
1 note
·
View note
Photo
Well played pal but Doesn’t replaceAll() uses loop internally? by isuleman https://www.reddit.com/r/ProgrammerHumor/comments/cj7lzg/well_played_pal_but_doesnt_replaceall_uses_loop/?utm_source=ifttt
1 note
·
View note