How to select/read/copy values after specific character in a string

How to select/read/copy values after specific character in a string

Content Index :

How to select/read/copy values after specific character in a string
Tag : c , By : Tink
Date : November 29 2020, 01:01 AM

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

I am trying to read a file and copy every character read into a character array and print it in JAVA

Tag : java , By : Chris Woods
Date : March 29 2020, 07:55 AM
like below fixes the issue I am trying to read a file and copy every character as it is read into a character array and then print it. The output is just displaying the last character read from the file. , int ind = 0; should be before the loop.
int ind = 0;
while((s = f.read()) != -1 )
    pt[ind] = (char) s ;
    ind ++ ;


extracting values starting at a specific character string and up until a certain character string

Tag : .net , By : jamerson
Date : March 29 2020, 07:55 AM
To fix this issue to the fact that .NET regex supports repeated groups, you can use
var s = "WHERE ([EXTENT1].[MY_ID] IN (151,152,214,218,931,932,933,1067,1412,1414,13807,14347,14349,14446)) AND ([EXTENT1].[MY_OTHER_ID] IN (14264, 14335, 14385, 14398, 14603, 14650, 15164, 15374)) AND ([EXTENT2].[PERSON_ID] IN (28,933,14446,179,152,14349,14347,933,130,218,933,1067,931,151,214,152,933,145,931,145,5809,14347,14349,14349,1414,142,1412,179,152,14347,152,90,13807,932,931))\n    )  AS [FILTER1]\n    GROUP BY [K1], [K2]\n)  AS [GROUPBY1]"; 
var pattern = @"\.\[MY_ID]\s*IN\s*\(((?:,?(\d+))+)";
var matches = Regex.Matches(s, pattern);
var res1 = matches
                .Cast<Match>().Select(p => p.Groups[2].Captures) // Get a list of ind. numbers
var res2 = matches
                .Cast<Match>().Select(p => p.Groups[1].Value) // Get the whole substring
 foreach (var coll in res1)
    foreach (var v in coll)
 Console.WriteLine("Ex. 2");
    foreach (var v2 in res2)

SQL select first character following each occurrence of a specific character in string

Tag : sql-server , By : user113409
Date : March 29 2020, 07:55 AM
will help you If you want to use SQL for this, create a function with the following logic
SET @value = 'Hello.Bye.Today.Yesterday'

DECLARE @result VARCHAR(255)
DECLARE @curChar CHAR(1)

DECLARE @start INT, @end INT
SET @start = 2
SET @end = LEN(@value)

SET @result = SUBSTRING(@value, 1,1)

WHILE @start < @end
    SET @curChar = SUBSTRING(@value, @start, 1)
    IF @curChar = '.'
        SET @result = @result + SUBSTRING(@value, @start + 1, 1)
        SET @start = @start + 1
    SET @start = @start + 1

How to read a file character by character until a specific string is complete?

Tag : java , By : user152319
Date : March 29 2020, 07:55 AM
seems to work fine Here's a sample complete program that I have that illustrates how you can potentially do a match. NOTE: Using an array to store associations is a BAD IDEA if you have lookup performance. However, if you have to use an array, you simply need to iterate over the array, looking for the first lookup association that matches your search criteria.
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class OpCodeLookupService {

Pair[] opCodes;

public static final class Pair {
    String first;
    String second;

    public Pair(String first, String second) {
        this.first = first;
        this.second = second;

public OpCodeLookupService(Pair[] opCodes) {
    this.opCodes = opCodes;

public Pair pairLookup(String toLookup) {
    for(Pair p : this.opCodes) {
        if (p.first.equals(toLookup)) {
            return p;
    return null;

public String lookup(String filePath) {
    try {
        // In the comments, you mentioned you cannot use BufferedReader to ingest the file. In this example, I'm showing another way via Scanner which is a very easy to use class for ingesting input streams.
        Scanner s = new Scanner(new FileInputStream(filePath));
        StringBuilder stringToExamine = new StringBuilder();
        while (s.hasNext()) {
            String nextString = s.next();
            for (char c : nextString.toCharArray()) {
                Pair pair = pairLookup(stringToExamine.toString());
                if (pair != null) {
                    return pair.second;
        return null; //Indicates string is not found.
    } catch (FileNotFoundException e) {
        throw new RuntimeException("Cannot load file");

public static void main(String...args) {
    final Pair p = new Pair("thisisopcode", "12345");
    Pair[] pairs = new Pair[1];
    pairs[0] = p;
    OpCodeLookupService opService = new OpCodeLookupService(pairs);

JavaScript - Select string between specific word and next specific character on custom condition

Tag : javascript , By : Jay Crockett
Date : March 29 2020, 07:55 AM
around this issue I have a very long CSS code in a variable and I want to find the last matching condition in that. My code is: , Try this :)
var str = 'body { background: #fff; } .customClass{ font-size: 12px; } .anotherClass { color: #292929 } body { color : #fff } body{cool}';
var regex = /body\s+\{([^}]+)/g;
var temp;
var resultArray = [];
while ((temp = regex.exec(str)) != null)  
Related Posts Related QUESTIONS :
  • Searching an element in an Array using Recursive Function in C Language
  • Most fastest C code to count recursively directories in Linux ( without files )
  • Why does C not offer syntactically transparent references like C++ and Java do?
  • Code doesn't get excuted after using continue in while loop
  • How can I maintain correlation between structure definitions and their construction / destruction code?
  • Avoid race conditions when using pointers and threads
  • Binary and Decimal converting
  • How to create input tensors and use with interpreter in Tensorflow Lite (experimental C API)?
  • Unexpected typecasting between values in C
  • Trouble with Forking Process and Calling bc using execve
  • Glib Threads vs GMain Loop Eventing
  • Why does the byte sequence turn when I cast a char array to an integer array?
  • Is there any difference usage in external interrupt between GPIO (AHB bus)and those (APB bus)?
  • Trouble programming AVR to interpret input from Arduino rotary encoder module
  • Is it correct to use a do-while loop inside a for loop? Why and why not?
  • Why we can't use dot for new created pointers to structs
  • Atomicity of fprintf from MPI processes
  • Printing of negative value in c via printf
  • What's the difference between global or local variables regarding the main function?
  • movsd from memory to xmm0 in c x86-64 jit
  • Problem with a function that insert the content of a csv into an array of struct
  • Segmentation Fault running time on sem_post(flag)
  • Extracting values from an incoming bluetooth serial on an arduino
  • "How much memory space does an array takes if the maximum size that is declared is not used?"
  • C GTK2 frustrated with gnome documentation
  • What really happens when a dynamic memory allocation is explicitly converted to struct type?
  • Re-Indexing Bits Within a Char
  • pointer de-referencing balagurusamy
  • Is it safe to memcpy regex_t?
  • Find a tight upper bound on complexity of the below program:
  • FFTW results differ from FFT in MATLAB
  • How to fix Misra 2012 violation , " Assignment operation in expression "
  • What is the difference between "int *p =0;" and "int *p; *p=0;"
  • Strncpy gives unwanted characters at end of string
  • What is really happening behind when a constant is assigned to a pointer variable?
  • Having trouble tracking logic of program includes Fork()
  • Are leftshift operators dependent on register size?
  • How to pass and receive back pointer to array of structures?
  • How to convert 2 bytes into a signed short in C
  • Using while loop to print Ascii Table with 10 characters per line
  • Is it possible to compress binary files with Huffman-encoding?
  • Why I am getting missing terminating " character?
  • Function call problem in data structure learning
  • Getting a segmentation fault trying to pass a node
  • Copying chars from file into an array
  • How to measure the time in seconds between two characters while user inserting them as an input
  • How to print two strings on the same line in c
  • Passing ("text"+1) argument to Strlen function in C. Why is Output 3?
  • to find the total no of letter in a string. please checkout my code too
  • Why do hiredis functions use void* instead of redisReply*?
  • Is there any case where the C static keyword should or could be used in header files for variables?
  • Sort an array in the relative order of elements of another array in c
  • Why functional programming over c
  • Re-assign value to variable if rand() repeats a number
  • does decrementing a NULL pointer lead to undefined behavior?
  • Access global variable value in different .c files present in different paths
  • Voltage Measurement on STM32
  • Printf behaviour with $ notation when sequence of arguments incomplete
  • Using "extern" to declare functions with no parameters
  • Stop mex function (C) without closing MATLAB
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com