rex | Friendly regular expressions for R | Regex library
kandi X-RAY | rex Summary
kandi X-RAY | rex Summary
Friendly regular expressions for R.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rex
rex Key Features
rex Examples and Code Snippets
Community Discussions
Trending Discussions on rex
QUESTION
In the following example we are using a reference to self
in the println!
and show_type
functions yet we aren't dereferencing self
with *
to get the value.
Why aren't we using dereference in the example?
When do we need to use a dereference?
How can we print to screen if a variable is holding a reference or a value?
...ANSWER
Answered 2022-Feb-22 at 13:16Field access expressions do automatic dereferncing in Rust: https://doc.rust-lang.org/reference/expressions/field-expr.html#automatic-dereferencing
And so I guess you would dereference manually when you need a whole value, not a specific field.
QUESTION
I'm trying to wrap my head around the x86 instruction encoding format. All the sources that I read still make the subject confusing. I'm starting to understand it a little bit but one thing that I'm having trouble with understanding is how the CPU instruction decoder differentiates an opcode prefix from an opcode.
I'm aware that the whole format of the instruction basically depends on the opcode (with extra bit fields defined in the opcode of course). Sometimes the instruction doesn't have a prefix and the opcode is the first byte. How would the decoder know?
I'm assuming that the instruction decoder would be able to tell the difference because opcode bytes and prefix bytes would not share the same binary values. So the decoder can tell if the unique binary number in the byte is an instruction or a prefix. For example (In this example we will stick to single byte opcodes) a REX or LOCK prefix would not share the same byte value as any opcode in the architecture's instruction set.
...ANSWER
Answered 2022-Feb-23 at 02:47Traditional (single-byte) prefixes are different from opcode bytes like you said, so a state machine can just remember which prefixes it's seen until it gets to an opcode byte.
The 0f
escape byte for 2-byte opcodes is not really a prefix. It has to be contiguous with the 2nd opcode byte. Thus, following a 0f
, any byte is an opcode, even if it's something like f2
that would otherwise be a prefix. (This also applies following 0f 3a
or 0f 38
2-byte escapes for SSSE3 and later, or VEX/EVEX prefixes that encode one of those escape sequences).
If you look at an opcode map, there are no entries that are ambiguous between single-byte prefix and opcode. (e.g. http://ref.x86asm.net/coder64.html, and notice how the 2-byte 0F .. opcodes are listed separately).
The decoders do have to know the current mode for this (and other things); for example x86-64 removed the 1-byte inc/dec reg
opcodes for use as REX prefixes. (x86 32 bit opcodes that differ in x86-x64 or entirely removed). We can even use this difference to write polyglot machine code that runs differently when decoded in 32-bit vs. 64-bit mode, or even distinguish all 3 mode sizes.
x86 machine code is a byte stream that's not self-synchronizing (e.g. a ModRM or an immediate can be any byte). The CPU always knows where to start decoding from, either a jump target or the byte after the end of a previous instruction. That's the start of the instruction (including prefixes).
Bytes in memory are just bytes, only becoming instructions when they're decoded by the CPU. (Although in normal programs, simply disassembling from the top of the .text
section does give you the program's instructions. Self-modifying and obfuscated code are not normal.)
Multi-byte VEX and EVEX prefixes aren't that simple in 32-bit mode. For example VEX prefixes overlap with invalid encodings of LES and LDS in modes other than 64-bit. (The c4
and c5
opcodes for LES and LDS are always invalid in 64-bit mode, except as VEX prefixes.) https://wiki.osdev.org/X86-64_Instruction_Encoding#VEX.2FXOP_opcodes
In legacy / compat modes, there weren't any free bytes left that weren't already opcodes or prefixes when AVX (VEX prefixes) and AVX-512 (EVEX prefix), so the only room for extensions was as encodings for opcodes that are only valid with a limited set of ModRM bytes. (e.g. LES / LDS require a memory source, not register - this is why some bits are inverted in VEX prefixes, so the top 2 bits of the byte after c4
or c5
will always be 1
in 32-bit mode instead of 0
.
That's the "mode" field in ModRM, and 11
means register).
(Fun fact: VEX prefixes are not recognized in 16-bit real mode, apparently because some software used the same invalid encodings of LES / LDS as intentional traps, to be sorted out in the #UD exception handler. VEX prefixes are recognized in 16-bit protected mode, though.)
AMD64 freed up several bytes by removing instructions like AAM, as well as LES/LDS (and the one-byte inc
/dec reg
encodings for use as REX prefixes), but CPU vendors have continued to care about 32-bit mode and not added any extensions that are only available in 64-bit mode which could simply take advantage of those free opcode bytes. This means finding ways to cram new instruction encodings into increasingly small gaps in 32-bit machine code. (Often via mandatory prefixes, e.g. rep bsr
= lzcnt
on CPUs with that feature, which gives different results.)
So the decoders in modern CPUs that support AVX / BMI1/2 have to look at multiple bytes to decide whether this is a prefix for a valid AVX or other VEX-encoded instruction, or in 32-bit mode if it should decode as LES or LDS. (And I guess look at the rest of the instruction to decide if it should #UD).
But modern CPUs are looking at 16 or 32 bytes at a time anyway to find instruction boundaries in parallel. (And then later feed those groups of instruction bytes to actual decoders, again in parallel.) https://www.realworldtech.com/sandy-bridge/4/
Same goes for the prefix scheme used by AMD XOP, which is a lot like VEX.
Agner Fog's blog article Stop the instruction set war from 2009 (soon after AVX was announced, before the first hardware supporting it) has a table of remaining unused coding space for future extensions, and some notes about it being "assigned" to AMD, Intel, or Via.
Related / examples- How to tell the length of an x86 instruction? (including my answer) has some more details about x86 machine code.
- https://codegolf.stackexchange.com/questions/133486/find-an-illegal-string/133622#133622 (on codegolf.SE - the shortest sequence of bytes that will definitely #UD fault if it's not jumped over. It has to be long enough that it can't be consumed by the CPU as the immediate for a
mov r64, imm64
for example.) - Why does x/i on gdb give different results then disassemble? - an example of starting decode in the wrong place and decoding the middle of another instruction as something else.
(This is not really related to prefixes, but in general seeing how the rules apply to weird cases can help understand exactly things work.)
A software disassembler does need to know a start point. This can be problematic if obfuscated code mixes code and data, and actual execution jumps to places you wouldn't get if you just assume that you can decode in order without following jumps.
Fortunately compiler-generated code doesn't do that so naive static disassembly (e.g. by objdump -d
or ndisasm
, as opposed to IDA) finds the same instruction boundaries that actually running the program will.
This is not a problem for running obfuscated machine code; the CPU just does what it's told, and never cares about bytes before the place you tell it to jump to. Disassembling without running / single-stepping the program is the hard thing, especially with the possibility of self-modifying code and jumps to what a naive disassembler would think was the middle of an earlier instruction.
Obfuscated machine code can even have an instruction decode one way, then jump back into what was the middle of that instruction, for a later byte to be the opcode (or prefix + opcode). Modern CPUs with uop caches or that mark instruction boundaries in I-cache run slow (but correctly) if you do this, so it's more of a fun code-golf trick (extreme code-size optimization at the expense of speed) or obfuscation technique.
For an example of this, see my codegolf.SE x86 machine code answer to Golf a Custom Fibonacci Sequence. I'll excerpt the disassembly that lines up with what the CPU sees after looping back to cfib.loop
, but note that the first iteration decodes differently. So I'm using just 1 byte outside the loop instead of 2 to effectively jump into the middle for the start of the first iteration. See the linked answer for a full description and the other disassembly.
QUESTION
I have this error "Uncaught TypeError: Cannot read properties of undefined (reading '_currentQuest') main.js:67
I tri to change my code but all time i already have this error...
If someone help me that will be great. Idk what can i change in my code because i see tutorial and i write like the tuto / answer
...ANSWER
Answered 2022-Feb-14 at 16:03There are several points to fix:
the is mixture of global variables and property, choose one an stick to it.
- simple solution replace all
this.player
withplayer
- simple solution replace all
define the player variable before starting the quest. (since the quest tries to access the
player
variable)- simple solution move the
player
definition ontop on the quest definitionthis.plugins.get('rexquestplugin')
.
- simple solution move the
The variable
Connor
is not defined- simple solution add
var Connor;
to your code
- simple solution add
Here you can see this changes implemented:
QUESTION
I search and I don't find anything to do quest in Phaser3. I want to do a quest like (it's example).
Go talk to 'Jerry'.
Take a sword and give it to 'Jerry'.
When you finish to talk it unlock a door or other, but I need to know how can I check if he talk to the PNJ and how to set a quest simply
I found rexquestplugin but I do'nt know how to use it and there is no website or other it talk about RexQuest
My code for now if you need to know something about the game:
...ANSWER
Answered 2022-Feb-07 at 12:20I never really used rexquestplugin
, but is sounded interesting so I checked it out.
Here the Documentation (it is not detailed, but might help clear up the code below)
The Demo on the Documentation Site helped me to understand the usage better, but it is not very clear.
So I wrote a small demo app, to answer the question "how would I solve your question, with the plugin?"
(btw.: You can execute the snippet below)
QUESTION
I'm trying to do a visualiser like this: Visualiser Audio js
But with the file that is on my pc not one that the customer can choose. Like here the file is on my pc.
...ANSWER
Answered 2021-Dec-18 at 21:34For your audio element, try setting the crossorigin
attribute to use-credentials
.
QUESTION
i'm new and after finishing my site i realized the parts i created are not responsive is there a way to fix it without starting from scratch?
...ANSWER
Answered 2021-Dec-14 at 18:18Because you are using vw in certain places, this unit takes a fixed percentage of browser size of 50vw mean 500px of 1000px screen and 50px of 100px screen, I would suggest to use rem instead also, you can go a bit advanced and use css clamp() to fix width of multiple screen at once.
QUESTION
I am trying to implement a printAnimals() method that prints the ArrayList for dogs or prints the ArrayList for monkeys, or prints all animals whose training status is "in service" and whose is Not reserved, depending on the input you enter in the menu. I am trying to correctly write a for loop for both ArrayList that contains if statements, so it will print whatever item in the ArrayList meets the conditions, which are that their trainingStatus equals "in service" and that reserved = false.
I currently have an error under printAnimals() method that says "The method dogList(int) is undefined for type Driver" and another error message that says "The method monkeyList(int) is undefined for type Driver". Do you know how to correctly type a for loop that iterates through an ArrayList and has if statements? Here is the code I have so far:
...ANSWER
Answered 2021-Dec-12 at 21:49Looks for me an error here:
QUESTION
my logs in splunk like:
...ANSWER
Answered 2021-Nov-09 at 10:53In Splunk, only named capturing groups must be used to extract data into fields. So, the numbered capturing group in your regex does not do anything meaningful for Splunk. You need to use New_Field
group around the pattern part you need to extract.
Also, you only matched C
, you can match any uppercase letter with [A-Z]
, or if there are more than one, [A-Z]+
.
You can use
QUESTION
When visiting the website this element contains the date: 20210930
...ANSWER
Answered 2021-Nov-14 at 17:26The text 20210930 isn't the innerText
but the value within. So text attribute won't be able to retrive it. You need to use get_attribute("value")
inducing WebDriverWait as follows:
Using
CSS_SELECTOR
:
QUESTION
In Splunk, I am looking for logs that say "started with profile: [profile name]" and retrieve the profile name from found events. Then I want to use the profile name to look for other events (from a different source) and if one error or more are found, I would like to let it count as one found error, per platform.
To make things more clear I have the following search query (query one):
...ANSWER
Answered 2021-Oct-27 at 14:16First ... don't dedup
on _raw
The _raw
events are never duplicated (unless you've done something wrong on ingest)
Second, to your actual question - try something along the lines of this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rex
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page