Regular expression – lookup $ in the string

Based on the suggestion here: Find location of character in string, I tried this:

> gregexpr(pattern = '$',"data.frame.name$variable.name")
[[1]]
[1] 30
attr(,"match.length")
[1] 0
attr(,"useBytes")
[1] TRUE

But it does not work; Note:

< pre>> nchar(“data.frame.name$variable.name”)
[1] 29

How do you find the position of $ in this string?

The problem is that $ is the end-of-string tag in the regular expression. Try this:

> gregexpr(pattern ='\$',"data.frame.name$variable.name")
[[1]]
[1] 16
attr(,"match.length")
[1] 1
attr(,"useBytes")
[1] TRUE

< p>…gave the correct answer – namely 16.

Based on the suggestion here: Find location of character in string, I tried this:

> gregexpr(pattern ='$',"data.frame.name$variable.name")
[[1]]
[1] 30
attr(,"match.length")
[1] 0
attr(,"useBytes")
[1] TRUE

But it doesn’t Works; note:

> nchar("data.frame.name$variable.name")
[1] 29

You How to find the position of $ in this string?

The problem is that $ is the end of string token in regular expressions. Try this:

> gregexpr(pattern ='\$',"data.frame.name$variable.name")
[[1]]
[1] 16
attr(, "match.length")
[1] 1
attr(,"useBytes")
[1] TRUE

… gives the correct answer – that is 16 .

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5435 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.