我需要从URL地址获取文件名.
以下是标准:
它需要""在以下场景中返回空字符串:
http://somedomain.com
http://www.somedomain.com
http://somedomain.com/
http://www.somedomain.com/
Run Code Online (Sandbox Code Playgroud)
并在以下场景中返回filename.php:
http://somedomain.com/filename.php?query
http://www.somedomain.com/filename.php?query
http://somedomain.com/filename.php#query
http://www.somedomain.com/filename.php#query
Run Code Online (Sandbox Code Playgroud)
我找到了这个正则表达式
[\w_.-]*?(?=[\?\#])|[\w_.-]*$从这里开始
但它会somedomain.com在输入时返回http://somedomain.com.我无法弄清楚如何修改它以忽略域,当它没有/结束时.
如果使用正则表达式很难,我也会欣赏JavaScript解决方案.
Thanx提前.
如何使用以下代码将我输出的记录数限制为仅3条记录:
User.rb
def workouts_on_which_i_commented
comments.map{|x|x.workout}.uniq
end
def comment_stream
workouts_on_which_i_commented.map do |w|
w.comments
end.flatten.sort{|x,y| y.created_at <=> x.created_at}
end
Run Code Online (Sandbox Code Playgroud)
html.erb文件
<% current_user.comment_stream.each do |comment| %>
...
<% end %>
Run Code Online (Sandbox Code Playgroud)
更新:
我正在使用Rails 2.3.9
如何在UITabBar中创建凸起的项目?
例如,Instagram有这个:

我如何在我的应用程序中实现类似的功能?
我的应用程序布局有一个登录/注销链接,根据您是否已登录显示:
<% if signed_in? %>
<%= link_to "Sign out", signout_path, :method => :delete %>
<% else %>
<%= link_to "Sign in", signin_path %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
这很好,但看起来真的不整洁,冗长.如何在没有这么多<%...%>括号的情况下输出相应的link_to?
我无法让我的本地计算机运行SQL Server.我查看了SQL Server配置管理器,发现没有列出SQL Server服务.这不可能是正确的.我还注意到SysWOW64文件夹中列出了两个Managers(我正在运行Win7):SQLServerManager10.msc和SQLServerManager.msc.根本不显示任何服务.当尝试通过SSMSE连接时,我得到了标准:
A network related or instance specific error occurred while establishing a
connection to SQL server...
Run Code Online (Sandbox Code Playgroud)
我没有安装以前的版本,但尝试使用Microsoft的Web平台安装程序卸载并重新安装.有什么建议?
谢谢
曾经有一个PHP扩展可以加载Java库并调用其中的方法.那是PHP 4.
有没有办法在PHP 5中做同样的事情?
我试图创建一个ListPreference但不知何故禁用其中一个项目.有点像灰色或其他东西,没有能力选择它.这将是一个即将推出的功能,我希望它在列表中是不可选择的.
我已经创建了一个自定义ListPreference类,并在该类中自定义适配器,希望使用适配器来创建我想要的.
代码工作,它设置适配器,但没有调用任何适配器函数.我在方法上设置断点,例如getCount()但它们永远不会被调用.
这是我的代码.自定义ListPreference取自http://blog.350nice.com/wp/archives/240
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.preference.ListPreference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.app.AlertDialog.Builder;
public class CustomListPreference extends ListPreference {
private boolean[] mClickedDialogEntryIndices;
CustomListPreferenceAdapter customListPreferenceAdapter = null;
Context mContext;
public CustomListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mClickedDialogEntryIndices = new boolean[getEntries().length];
}
@Override
protected void onPrepareDialogBuilder(Builder builder) {
CharSequence[] entries = getEntries();
CharSequence[] entryValues = getEntryValues();
if (entries == null || entryValues …Run Code Online (Sandbox Code Playgroud) 我需要在我的简单应用程序中添加一个功能 - 允许用户更改整个应用程序的字体大小.这很容易吗?你能给我一些提示如何开始吗?它只需要3个预定义的字体大小,但我想到的第一个也是唯一的解决方案是创建3个不同的主题.有可能使它更简单吗?
PowerShell函数能否确定它是否作为管道的一部分运行?我有一个函数,它填充一个数组,FileInfo如果函数以这种方式运行,我希望"屈服"到管道的实例,或者如果函数是从命令行自己调用的话,产生一些漂亮的输出.
function Do-Something {
$file_infos = @()
# Populate $file_infos with FileInfo instances...
if (INVOKED_IN_PIPELINE) {
return $file_infos
}
else {
foreach ($file_info in $file_infos) {
write-host -foregroundcolor yellow $file_info.fullname
}
}
}
Run Code Online (Sandbox Code Playgroud)
基本上,我正在试图弄清楚如何实施INVOKED_IN_PIPELINE.如果它在一个管道(例如Do-Something | format-table fullname)中运行,我只会产生数组,但如果直接运行(例如Do-Something),它会将数组的内容漂亮地打印到控制台.
有没有办法做到这一点?如果有更"惯用"的方式来实现这种事情,我也有兴趣知道.
php ×2
android ×1
binding ×1
cocoa-touch ×1
erb ×1
filenames ×1
ios ×1
iphone ×1
java ×1
javascript ×1
limit ×1
listadapter ×1
powershell ×1
regex ×1
ruby ×1
sql-server ×1
url ×1
wpf ×1
wpf-controls ×1
xaml ×1