Categories
Mastering Development

regex alphanumeric, but when it gets a numeric, then only numeric

I need to validate an input that must start with an alpha, and then it can be alphanumeric, but once numeric; it must be numeric to the end of the string. [a-z][a-z,0-9]{1,5} This does only part of the job. So it validates correctly for a1 abc12 ab123 but I do not want a1b2c1 so onces […]

Categories
Development

Why is my regex string not matching as a whole while individual components of the whole do match?

I’m trying to use a regular expression to match a string of the type 16 June 1997. The pattern isn’t that complicated, and when I try and match individual components of the larger regex string, it matches just fine. But for some reason, I’m having trouble matching the entire regex string. I’m honestly at a […]

Categories
Development

Pattern Matching in Oracle SQL

I am trying to match some patterns and exclude some based on certain characters and lengths. I want to return all 3 characters and 4 characters values: The 3 character values should have any letter at 3rd position i.e 11A The 4 character values should have 2 letters at the end i.e 11AB, but shouldn’t […]

Categories
Development

In R, how can I use argmax function by row and count the variable number?

I have the raw dataset. The below is sample of raw data: sentiment pos neu neg likes_count 1 1 0 0 5 2 0.2 0.3 0.5 6 3 0.3 0.3 0.4 6 4 0 0 1 3 5 0.2 0.7 0.1 1 In this raw data of sentiment, “pos” refers to probability of positivity in […]

Categories
Development

Regex: 0 to 10, with two digits after the dot, if necessary. Java [duplicate]

This question already has an answer here: Regular Expression for Integer greater than 0 and less than 11 7 answers Regex to match 2 digits, optional decimal, two digits 10 answers I created this Regex: ^[1][0-9]{1,2}[.,]?[0-9]{1,2}+$ Why this Regex doesn’t see values like 1 or 9? (I use {1-2}) How to prevent 0 with out […]

Categories
Development

Opengl viewpoint transformation how to gluLookAt

I would like to use the polar coordinates to manipulate the upper, lower, left, and right camera points with my keyboard. #include <stdlib.h> #include <glut.h> GLint TopLeftX, TopLeftY, BottomRightX, BottomRightY ; static int HourOfDay = 0; static int DayOfYear = 10; void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); } void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); […]

Categories
Development

Regex.Replace function with max-length

I’m using the Regex.Replace() function to only allow Integers on a TextBox. texbox.Text = Regex.Replace(texbox.Text, “[^0-9]”, “”); Then I needed to add a max-length = 4 on it, but it doesn’t work. texbox.Text = Regex.Replace(texbox.Text, “[^0-9]{1,4}$”, “”); I think I’m missing the logic but I couldn’t solve it. I don’t want to set the max-length […]

Categories
Development

Connecting points with ggplot in R

I’m looking for a way to connect some points using ggplot in R. I want to connect each point to the nearest point. Here’s what my data look like as a scatter plot. x <- c(0.81,0.82,0.82,0.82,0.83,0.83,0.83,0.84,0.84,0.84,0.85,0.85,0.85,0.86,0.86,0.86,0.87,0.87,0.87,0.88,0.88,0.88,0.89,0.89,0.89,0.9,0.9,0.9,0.91,0.91,0.91,0.92,0.92,0.92,0.93,0.93,0.93,0.93,0.93,0.94,0.94,0.94,0.94,0.94,0.95,0.95,0.95,0.95,0.95,0.96,0.96,0.96,0.96,0.96,0.97,0.97,0.97,0.97,0.97,0.98,0.98,0.98,0.98,0.98,0.99,0.99,0.99,0.99,1,1,1,1,1.01,1.01,1.01,1.01,1.02,1.02,1.02,1.02,1.03,1.03,1.03,1.03,1.04,1.04,1.04,1.04,1.05,1.05,1.05,1.05,1.06,1.06,1.06,1.06,1.07,1.07,1.07,1.07,1.08,1.08,1.08,1.08,1.09,1.09,1.09,1.09,1.1,1.1,1.1,1.1,1.11,1.11,1.11,1.11,1.12,1.12,1.12,1.12,1.13,1.13,1.13,1.13,1.14,1.14,1.15,1.15,1.16,1.16,1.17,1.17,1.18,1.18,1.19,1.19,1.2,1.2,1.21,1.21,1.22,1.22,1.23,1.23,1.24,1.24,1.25,1.25,1.26,1.26,1.27) y <- c(-1.295,-0.535,-1.575,-1.295,-0.525,-1.575,-1.295,-0.515,-1.575,-1.285,-0.515,-1.575,-1.285,-0.505,-1.575,-1.275,-0.495,-1.575,-1.275,-0.485,-1.575,-1.265,-0.485,-1.575,-1.265,-0.475,-1.575,-1.255,-0.465,-1.575,-1.255,-0.455,-1.575,-1.245,-0.445,1.285,1.545,-1.575,-1.245,-0.435,1.165,1.675,-1.575,-1.235,-0.425,1.085,1.765,-1.575,-1.235,-0.405,1.015,1.845,-1.575,-1.225,-0.395,0.965,1.905,-1.575,-1.215,-0.385,0.915,1.965,-1.575,-1.215,-0.375,0.865,-1.575,-1.205,-0.355,0.825,-1.575,-1.205,-0.345,0.785,-1.565,-1.195,-0.325,0.745,-1.565,-1.185,-0.305,0.705,-1.565,-1.185,-0.285,0.665,-1.565,-1.175,-0.265,0.625,-1.565,-1.165,-0.245,0.585,-1.565,-1.165,-0.225,0.545,-1.565,-1.155,-0.195,0.495,-1.555,-1.145,-0.165,0.455,-1.555,-1.145,-0.135,0.405,-1.555,-1.135,-0.0849999999999999,0.345,-1.555,-1.125,-0.035,0.275,-1.545,-1.115,0.0850000000000001,0.145,-1.545,-1.115,-1.545,-1.105,-1.545,-1.095,-1.535,-1.085,-1.535,-1.085,-1.535,-1.075,-1.525,-1.065,-1.525,-1.055,-1.525,-1.045,-1.515,-1.045,-1.515,-1.035,-1.505,-1.025,-1.505,-1.015,-1.495,-1.005,-1.495) example_df <- tibble(x = x, y = y) ggplot(example_df, aes(x = x, y = y)) + […]

Categories
CSV Development

Space padding in a CSV string using regex

In Python, I’m trying to space-pad numbers in a CSV string with regex’s. I can of course do this with split(), format(), and join(), but my constraint is to use a regex. Why is the following re.sub only doing substitutions on found matches 0,2,4,6,8? It’s skipping every other match. import re # trying to pad […]

Categories
Development

Regular Expression Help to parse ffmpeg info

I would appreciate if anyone could help me with this Input #0, mpegts, from ‘tcp://127.0.0.1:3456’: Duration: N/A, start: 1809.522000, bitrate: N/A Program 256 Metadata: service_name : AIR_CH_521_6M service_provider: ITE Stream #0:0[0x7d1]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920×1080, 30 fps, 30 tbr, 90k tbn, 60 tbc Stream #0:1[0x7d2]: Audio: mp3 ([4][0][0][0] / 0x0004), […]