Question: I have a data grouped data, 

```
df <- data.frame(group_id= c(1, 1, 1, 1, 2, 1, 2, 3, 4),
                words = c("beach", "sand", "trip", "warm","travel", "water","beach","sand", "trees"),
                 ID = c("vacation", "vacation", "vacation", "vacation", "meeting","vacation","meeting","onduty", "hiking"))

```

The `group_id` is groups of `ID` column. Now I want to check certain patterns ("beach" or "warm" or "sand") for each group, and print the matching pattern in separate column and matches 0 (no match) or 1 (yes macth) in separate column.

Expected :

```
  id  words       ID           pattern Match
1  1  beach vacation Beach, sand, warm 1
2  1   sand vacation Beach, sand, warm 1
3  1   trip vacation Beach, sand, warm 1
4  1   warm vacation Beach, sand, warm 1
5  2 travel  meeting Beach             1
6  1  water vacation Beach, sand, warm 1
7  2  beach  meeting Beach             1
8  3   sand   onduty sand              1
9  4  trees  hiking  0                 0

```

Answer: 
Skip `\r\n` is for Windows.

The rest is standard `\r=CR`, `\n=LF` (see [\r\n , \r , \n what is the difference between them?](https://stackoverflow.com/questions/15433188/r-n-r-n-what-is-the-difference-between-them))

Then some Unicode special characters:

`u2028 = LINE SEPARATOR` (<https://www.fileformat.info/info/unicode/char/2028/index.htm>)

`u2029 = PARAGRAPH SEPARATOR` 
(<http://www.fileformat.info/info/unicode/char/2029/index.htm>)

`u0085 = NEXT LINE` (<https://www.fileformat.info/info/unicode/char/0085/index.htm>)
I have a much simpler exercise to explain this

```
  public class Solution {
    public static void main(String[] args) {
    int i = 4;
    double d = 4.0;
    String s = "HackerRank ";

    Scanner scan = new Scanner(System.in);

    int a;
    double b;
    String c = null;

    a = scan.nextInt();
    b = scan.nextDouble();
    c = scan.nextLine();

    System.out.println(c);
    scan.close();
    System.out.println(a + i);
    System.out.println(b + d);
    System.out.println(s.concat(c));
   }
}

```

TRY running this.. FIRST and see the output

After that

```
 public class Solution {

public static void main(String[] args) {
    int i = 4;
    double d = 4.0;
    String s = "HackerRank ";

    Scanner scan = new Scanner(System.in);

    int a;
    double b;
    String c = null;

    a = scan.nextInt();
    b = scan.nextDouble();
    scan.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
    c = scan.nextLine();

    System.out.println(c);
    scan.close();
    System.out.println(a + i);
    System.out.println(b + d);

    System.out.println(s.concat(c));
 }
}

```

TRY THIS AGAIN..

This can be a very tricky interview question

I cursing myself before I could realise the issue..

Just ask any programmer
to take an integer number
to take an double number
and a string 
ALL FROM USER INPUT

If they don't know this.. they will most definitely fail..

You can find a much simpler answer about the behaivor of the integer and the double in their javadocs